Update some deprecated code
Documentation Fix "/*" comments to "/**" Flesh out some missing returns, change some return types
This commit is contained in:
parent
d542379925
commit
27665d27ae
18 changed files with 90 additions and 44 deletions
2
api.php
2
api.php
|
|
@ -117,7 +117,7 @@ $processor = new ApiMain( $wgRequest, $wgEnableWriteAPI );
|
|||
$processor->execute();
|
||||
|
||||
// Execute any deferred updates
|
||||
wfDoUpdates();
|
||||
DeferredUpdates::doUpdates();
|
||||
|
||||
// Log what the user did, for book-keeping purposes.
|
||||
$endtime = microtime( true );
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class Block {
|
|||
$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 );
|
||||
|
|
|
|||
|
|
@ -17,6 +17,15 @@ class CategoryPage extends Article {
|
|||
# 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 );
|
||||
|
|
@ -69,7 +78,7 @@ class CategoryPage extends Article {
|
|||
$oldUntil = $request->getVal( 'until' );
|
||||
|
||||
$reqArray = $request->getValues();
|
||||
|
||||
|
||||
$from = $until = array();
|
||||
foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
|
||||
$from[$type] = $request->getVal( "{$type}from", $oldFrom );
|
||||
|
|
@ -101,7 +110,7 @@ class CategoryViewer extends ContextSource {
|
|||
$imgsNoGallery;
|
||||
|
||||
/**
|
||||
* @var
|
||||
* @var
|
||||
*/
|
||||
var $nextPage;
|
||||
|
||||
|
|
@ -236,7 +245,7 @@ class CategoryViewer extends ContextSource {
|
|||
}
|
||||
$this->children[] = $link;
|
||||
|
||||
$this->children_start_char[] =
|
||||
$this->children_start_char[] =
|
||||
$this->getSubcategorySortChar( $cat->getTitle(), $sortkey );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3702,6 +3702,7 @@ $wgSummarySpamRegex = array();
|
|||
* - false : let it through
|
||||
*
|
||||
* @deprecated since 1.17 Use hooks. See SpamBlacklist extension.
|
||||
* @var callback
|
||||
*/
|
||||
$wgFilterCallback = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -923,7 +923,7 @@ class EditPage {
|
|||
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' );
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class MWException extends Exception {
|
|||
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 ] ) ) {
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ class RawPage {
|
|||
} else {
|
||||
return $this->getArticleText();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function getArticleText() {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
* @ingroup Media
|
||||
*/
|
||||
class WikiFilePage extends WikiPage {
|
||||
/**
|
||||
* @var File
|
||||
*/
|
||||
protected $mFile = false; // !< File object
|
||||
protected $mRepo = null; // !<
|
||||
protected $mFileLoaded = false; // !<
|
||||
|
|
@ -43,6 +46,7 @@ class WikiFilePage extends WikiPage {
|
|||
}
|
||||
}
|
||||
$this->mRepo = $this->mFile->getRepo();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getRedirectTarget() {
|
||||
|
|
@ -77,7 +81,7 @@ class WikiFilePage extends WikiPage {
|
|||
if ( $this->mFile->isLocal() ) {
|
||||
return parent::isRedirect( $text );
|
||||
}
|
||||
|
||||
|
||||
return (bool)$this->mFile->getRedirected();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -723,6 +723,9 @@ class LoadBalancer {
|
|||
wfProfileOut( __METHOD__ );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
function getWriterIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,13 +103,14 @@ class ExternalUser_vB extends ExternalUser {
|
|||
|
||||
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'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
/*
|
||||
/**
|
||||
* Copyright 2010 Wikimedia Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class Preprocessor_DOM implements Preprocessor {
|
|||
*/
|
||||
function memCheck() {
|
||||
if ( $this->memoryLimit === false ) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
$usage = memory_get_usage();
|
||||
if ( $usage > $this->memoryLimit * 0.9 ) {
|
||||
|
|
|
|||
|
|
@ -112,11 +112,11 @@ class SpecialImport extends SpecialPage {
|
|||
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 ) ) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ class SpecialUploadStash extends UnlistedSpecialPage {
|
|||
try {
|
||||
$this->stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
|
||||
} catch ( UploadStashNotAvailableException $e ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,17 +47,15 @@ class SpecialUploadStash extends UnlistedSpecialPage {
|
|||
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.
|
||||
|
|
@ -206,7 +203,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
|
|||
// 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.
|
||||
|
|
|
|||
|
|
@ -9,13 +9,18 @@
|
|||
|
||||
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;
|
||||
|
|
@ -40,7 +45,11 @@ class UploadFromStash extends UploadBase {
|
|||
|
||||
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 );
|
||||
|
|
@ -58,13 +67,17 @@ class UploadFromStash extends UploadBase {
|
|||
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'] ),
|
||||
|
|
@ -91,8 +104,11 @@ class UploadFromStash extends UploadBase {
|
|||
return $this->initialize( $fileKey, $desiredDestName );
|
||||
}
|
||||
|
||||
public function getSourceType() {
|
||||
return $this->mSourceType;
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSourceType() {
|
||||
return $this->mSourceType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -106,6 +122,8 @@ class UploadFromStash extends UploadBase {
|
|||
|
||||
/**
|
||||
* Stash the file.
|
||||
*
|
||||
* @return UploadStashFile
|
||||
*/
|
||||
public function stashFile() {
|
||||
// replace mLocalFile with an instance of UploadStashFile, which adds some methods
|
||||
|
|
@ -131,6 +149,11 @@ class UploadFromStash extends UploadBase {
|
|||
|
||||
/**
|
||||
* 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 );
|
||||
|
|
@ -141,7 +164,7 @@ class UploadFromStash extends UploadBase {
|
|||
/**
|
||||
* 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
|
||||
|
|
@ -153,7 +176,7 @@ class UploadFromStash extends UploadBase {
|
|||
//append chunk
|
||||
if ( $fileSize == $offset ) {
|
||||
$status = $this->appendToUploadFile( $chunk,
|
||||
$this->mVirtualTempPath );
|
||||
$this->mVirtualTempPath );
|
||||
} else {
|
||||
$status = Status::newFatal( 'invalid-chunk-offset' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@ class ImageCleanup extends TableCleanup {
|
|||
$this->progress( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name string
|
||||
*/
|
||||
private function killRow( $name ) {
|
||||
if ( $this->dryrun ) {
|
||||
$this->output( "DRY RUN: would delete bogus row '$name'\n" );
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ class ReassignEdits extends Maintenance {
|
|||
* 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 ) {
|
||||
|
|
|
|||
|
|
@ -5,12 +5,16 @@
|
|||
*/
|
||||
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;
|
||||
|
|
@ -64,7 +68,7 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
|
|||
for ($i = 0; $i < 100; $i++) {
|
||||
$this->user->mRights[$i] = $perm;
|
||||
}
|
||||
|
||||
|
||||
// Hack, hack hack ...
|
||||
$this->user->mRights['*'] = $perm;
|
||||
}
|
||||
|
|
@ -543,7 +547,7 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
|
|||
$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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue