$processor->execute();
// Execute any deferred updates
-wfDoUpdates();
+DeferredUpdates::doUpdates();
// Log what the user did, for book-keeping purposes.
$endtime = microtime( true );
$this->mAuto = $auto;
$this->isHardblock( !$anonOnly );
$this->prevents( 'createaccount', $createAccount );
- if ( $expiry == 'infinity' || $expiry == Block::infinity() ) {
+ if ( $expiry == 'infinity' || $expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
$this->mExpiry = 'infinity';
} else {
$this->mExpiry = wfTimestamp( TS_MW, $expiry );
# Subclasses can change this to override the viewer class.
protected $mCategoryViewerClass = 'CategoryViewer';
+ /**
+ * @var Title
+ */
+ protected $mTitle;
+
+ /**
+ * @param $title Title
+ * @return WikiCategoryPage
+ */
protected function newPage( Title $title ) {
// Overload mPage with a category-specific page
return new WikiCategoryPage( $title );
$oldUntil = $request->getVal( 'until' );
$reqArray = $request->getValues();
-
+
$from = $until = array();
foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
$from[$type] = $request->getVal( "{$type}from", $oldFrom );
$imgsNoGallery;
/**
- * @var
+ * @var
*/
var $nextPage;
}
$this->children[] = $link;
- $this->children_start_char[] =
+ $this->children_start_char[] =
$this->getSubcategorySortChar( $cat->getTitle(), $sortkey );
}
* - false : let it through
*
* @deprecated since 1.17 Use hooks. See SpamBlacklist extension.
+ * @var callback
*/
$wgFilterCallback = false;
wfProfileOut( __METHOD__ );
return $status;
}
- if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section, $this->hookError, $this->summary ) ) {
+ if ( $wgFilterCallback && is_callable( $wgFilterCallback ) && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section, $this->hookError, $this->summary ) ) {
# Error messages or other handling should be performed by the filter function
$status->setResult( false, self::AS_FILTERING );
wfProfileOut( __METHOD__ . '-checks' );
global $wgExceptionHooks;
if ( !isset( $wgExceptionHooks ) || !is_array( $wgExceptionHooks ) ) {
- return; // Just silently ignore
+ return; // Just silently ignore
}
if ( !array_key_exists( $name, $wgExceptionHooks ) || !is_array( $wgExceptionHooks[ $name ] ) ) {
} else {
return $this->getArticleText();
}
+ return '';
}
function getArticleText() {
* @ingroup Media
*/
class WikiFilePage extends WikiPage {
+ /**
+ * @var File
+ */
protected $mFile = false; // !< File object
protected $mRepo = null; // !<
protected $mFileLoaded = false; // !<
}
}
$this->mRepo = $this->mFile->getRepo();
+ return true;
}
public function getRedirectTarget() {
if ( $this->mFile->isLocal() ) {
return parent::isRedirect( $text );
}
-
+
return (bool)$this->mFile->getRedirected();
}
wfProfileOut( __METHOD__ );
}
+ /**
+ * @return int
+ */
function getWriterIndex() {
return 0;
}
private function getDb() {
global $wgExternalAuthConf;
- return new Database(
- $wgExternalAuthConf['server'],
- $wgExternalAuthConf['username'],
- $wgExternalAuthConf['password'],
- $wgExternalAuthConf['dbname'],
- 0,
- $wgExternalAuthConf['tablePrefix']
+ return DatabaseBase::factory( 'mysql',
+ array(
+ 'host' => $wgExternalAuthConf['server'],
+ 'user' => $wgExternalAuthConf['username'],
+ 'password' => $wgExternalAuthConf['password'],
+ 'dbname' => $wgExternalAuthConf['dbname'],
+ 'tablePrefix' => $wgExternalAuthConf['tablePrefix'],
+ )
);
}
<?php
-/*
+/**
* Copyright 2010 Wikimedia Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
*/
function memCheck() {
if ( $this->memoryLimit === false ) {
- return;
+ return true;
}
$usage = memory_get_usage();
if ( $usage > $this->memoryLimit * 0.9 ) {
if( $user->isAllowed( 'importupload' ) ) {
$source = ImportStreamSource::newFromUpload( "xmlimport" );
} else {
- return $this->getOutput()->permissionRequired( 'importupload' );
+ throw new PermissionsError( 'importupload' );
}
} elseif ( $sourceName == "interwiki" ) {
if( !$user->isAllowed( 'import' ) ){
- return $this->getOutput()->permissionRequired( 'import' );
+ throw new PermissionsError( 'import' );
}
$this->interwiki = $request->getVal( 'interwiki' );
if ( !in_array( $this->interwiki, $wgImportSources ) ) {
try {
$this->stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
} catch ( UploadStashNotAvailableException $e ) {
- return null;
}
}
public function execute( $subPage ) {
if ( !$this->userCanExecute( $this->getUser() ) ) {
$this->displayRestrictionError();
- return;
+ return false;
}
if ( $subPage === null || $subPage === '' ) {
return $this->showUploads();
- } else {
- return $this->showUpload( $subPage );
}
+ return $this->showUpload( $subPage );
}
-
/**
* If file available in stash, cats it out to the client as a simple HTTP response.
* n.b. Most sanity checking done in UploadStashLocalFile, so this is straightforward.
// do not use trailing slash
global $wgUploadStashScalerBaseUrl;
$scalerBaseUrl = $wgUploadStashScalerBaseUrl;
-
+
if( preg_match( '/^\/\//', $scalerBaseUrl ) ) {
// this is apparently a protocol-relative URL, which makes no sense in this context,
// since this is used for communication that's internal to the application.
class UploadFromStash extends UploadBase {
protected $mFileKey, $mVirtualTempPath, $mFileProps, $mSourceType;
-
+
// an instance of UploadStash
private $stash;
-
+
//LocalFile repo
private $repo;
-
+
+ /**
+ * @param $user User
+ * @param $stash UploadStash
+ * @param $repo FileRepo
+ */
public function __construct( $user = false, $stash = false, $repo = false ) {
// user object. sometimes this won't exist, as when running from cron.
$this->user = $user;
return true;
}
-
+
+ /**
+ * @param $key string
+ * @return bool
+ */
public static function isValidKey( $key ) {
// this is checked in more detail in UploadStash
return (bool)preg_match( UploadStash::KEY_FORMAT_REGEX, $key );
return self::isValidKey( $request->getText( 'wpFileKey', $request->getText( 'wpSessionKey' ) ) );
}
+ /**
+ * @param $key string
+ * @param $name string
+ */
public function initialize( $key, $name = 'upload_file' ) {
/**
* Confirming a temporarily stashed upload.
* We don't want path names to be forged, so we keep
* them in the session on the server and just give
* an opaque key to the user agent.
- */
+ */
$metadata = $this->stash->getMetadata( $key );
$this->initializePathInfo( $name,
$this->getRealPath ( $metadata['us_path'] ),
return $this->initialize( $fileKey, $desiredDestName );
}
- public function getSourceType() {
- return $this->mSourceType;
+ /**
+ * @return string
+ */
+ public function getSourceType() {
+ return $this->mSourceType;
}
/**
/**
* Stash the file.
+ *
+ * @return UploadStashFile
*/
public function stashFile() {
// replace mLocalFile with an instance of UploadStashFile, which adds some methods
/**
* Perform the upload, then remove the database record afterward.
+ * @param $comment string
+ * @param $pageText string
+ * @param $watch bool
+ * @param $user User
+ * @return Status
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
$rv = parent::performUpload( $comment, $pageText, $watch, $user );
/**
* Append a chunk to the temporary file.
*
- * @return void
+ * @return Status
*/
public function appendChunk($chunk, $chunkSize, $offset) {
//to use $this->getFileSize() here, db needs to be updated
//append chunk
if ( $fileSize == $offset ) {
$status = $this->appendToUploadFile( $chunk,
- $this->mVirtualTempPath );
+ $this->mVirtualTempPath );
} else {
$status = Status::newFatal( 'invalid-chunk-offset' );
}
$this->progress( 0 );
}
+ /**
+ * @param $name string
+ */
private function killRow( $name ) {
if ( $this->dryrun ) {
$this->output( "DRY RUN: would delete bogus row '$name'\n" );
* i.e. user => id, user_text => text
*
* @param $user User for the spec
- * @param $idfield Field name containing the identifier
- * @param $utfield Field name containing the user text
+ * @param $idfield string Field name containing the identifier
+ * @param $utfield string Field name containing the user text
* @return array
*/
private function userSpecification( &$user, $idfield, $utfield ) {
*/
class TitlePermissionTest extends MediaWikiLangTestCase {
protected $title;
- protected $user;
- protected $anonUser;
- protected $userUser;
- protected $altUser;
- protected $userName;
- protected $altUserName;
+
+ /**
+ * @var User
+ */
+ protected $user, $anonUser, $userUser, $altUser;
+
+ /**
+ * @var string
+ */
+ protected $userName, $altUserName;
function setUp() {
global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang;
for ($i = 0; $i < 100; $i++) {
$this->user->mRights[$i] = $perm;
}
-
+
// Hack, hack hack ...
$this->user->mRights['*'] = $perm;
}
$this->setTitle( NS_MAIN, "test page" );
$this->title->mTitleProtection['pt_create_perm'] = '';
$this->title->mTitleProtection['pt_user'] = $this->user->getID();
- $this->title->mTitleProtection['pt_expiry'] = Block::infinity();
+ $this->title->mTitleProtection['pt_expiry'] = wfGetDB( DB_SLAVE )->getInfinity();
$this->title->mTitleProtection['pt_reason'] = 'test';
$this->title->mCascadeRestriction = false;