From 374cce86c81e61f7e0aacc38defd4d2c35313c98 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sat, 22 Mar 2014 23:51:18 +0100 Subject: [PATCH] Update formatting for includes/specials/ Change-Id: I478dedd0b692eae002a0ca9b0ec15cb2c357411f --- includes/specials/SpecialActiveusers.php | 3 +- includes/specials/SpecialAllmessages.php | 2 +- includes/specials/SpecialAllpages.php | 1 + includes/specials/SpecialBooksources.php | 1 + includes/specials/SpecialChangePassword.php | 1 + includes/specials/SpecialContributions.php | 2 +- includes/specials/SpecialCreateAccount.php | 1 - .../specials/SpecialDeletedContributions.php | 2 +- includes/specials/SpecialEditWatchlist.php | 8 +-- includes/specials/SpecialExpandTemplates.php | 2 - includes/specials/SpecialFilepath.php | 1 + includes/specials/SpecialListfiles.php | 8 ++- includes/specials/SpecialMIMEsearch.php | 1 + includes/specials/SpecialMostrevisions.php | 1 + includes/specials/SpecialMovepage.php | 4 +- includes/specials/SpecialMyRedirectPages.php | 1 + includes/specials/SpecialNewimages.php | 1 + includes/specials/SpecialPermanentLink.php | 1 + includes/specials/SpecialRandomInCategory.php | 3 + includes/specials/SpecialRecentchanges.php | 3 + .../specials/SpecialRecentchangeslinked.php | 5 +- includes/specials/SpecialRedirect.php | 43 ++++++++----- includes/specials/SpecialResetTokens.php | 2 +- includes/specials/SpecialRevisiondelete.php | 15 ++++- includes/specials/SpecialRunJobs.php | 6 +- includes/specials/SpecialSearch.php | 30 +++++++-- includes/specials/SpecialShortpages.php | 19 +++--- includes/specials/SpecialStatistics.php | 64 ++++++++++--------- includes/specials/SpecialTags.php | 10 +-- includes/specials/SpecialUnblock.php | 4 +- .../specials/SpecialUncategorizedimages.php | 10 +-- .../specials/SpecialUncategorizedpages.php | 22 ++++--- includes/specials/SpecialUndelete.php | 60 +++++++++-------- includes/specials/SpecialUnusedcategories.php | 20 +++--- includes/specials/SpecialUnusedimages.php | 22 ++++--- includes/specials/SpecialUnusedtemplates.php | 17 +++-- includes/specials/SpecialUnwatchedpages.php | 17 +++-- includes/specials/SpecialUpload.php | 27 +++++--- includes/specials/SpecialUploadStash.php | 30 +++++---- includes/specials/SpecialUserlogin.php | 48 +++++++++++--- includes/specials/SpecialUserrights.php | 16 +++-- includes/specials/SpecialVersion.php | 25 +++++--- includes/specials/SpecialWantedcategories.php | 14 ++-- includes/specials/SpecialWantedfiles.php | 8 ++- includes/specials/SpecialWantedpages.php | 4 +- includes/specials/SpecialWantedtemplates.php | 21 +++--- includes/specials/SpecialWatchlist.php | 14 ++-- includes/specials/SpecialWhatlinkshere.php | 9 ++- includes/specials/SpecialWithoutinterwiki.php | 20 +++--- 49 files changed, 413 insertions(+), 236 deletions(-) diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index 1fed51652c..dd6bec2e6e 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -291,6 +291,7 @@ class SpecialActiveUsers extends SpecialPage { self::doQueryCacheUpdate( $dbw, $window ); } } + return ( time() - ( $cTime ? wfTimestamp( TS_UNIX, $cTime ) : $wgActiveUserDays * 86400 ) ); } @@ -383,7 +384,7 @@ class SpecialActiveUsers extends SpecialPage { $newRows = array(); foreach ( $names as $name => $lastEditTime ) { $newRows[] = array( - 'qcc_type' => 'activeusers', + 'qcc_type' => 'activeusers', 'qcc_namespace' => NS_USER, 'qcc_title' => $name, 'qcc_value' => wfTimestamp( TS_UNIX, $lastEditTime ), diff --git a/includes/specials/SpecialAllmessages.php b/includes/specials/SpecialAllmessages.php index 71bb27a1b5..6cef130b4d 100644 --- a/includes/specials/SpecialAllmessages.php +++ b/includes/specials/SpecialAllmessages.php @@ -352,7 +352,7 @@ class AllmessagesTablePager extends TablePager { 'grouppath' => 'mediawiki', 'query' => 'language:' . $this->getLanguage()->getCode() . '^25 ' . 'messageid:"MediaWiki:' . $value . '"^10 "' . - $this->msg ( $value )->inLanguage ( 'en' )->plain() . '"' + $this->msg( $value )->inLanguage( 'en' )->plain() . '"' ) ), $this->msg( 'allmessages-filter-translate' )->text() ); diff --git a/includes/specials/SpecialAllpages.php b/includes/specials/SpecialAllpages.php index 1e2d557b00..97e7238426 100644 --- a/includes/specials/SpecialAllpages.php +++ b/includes/specials/SpecialAllpages.php @@ -216,6 +216,7 @@ class SpecialAllpages extends IncludableSpecialPage { // since generating it will cause a lot of scanning if ( $count > $this->maxTopLevelPages ) { $this->showChunk( $namespace, $from, $to, $hideredirects ); + return; } diff --git a/includes/specials/SpecialBooksources.php b/includes/specials/SpecialBooksources.php index d19968fe96..79636b1eb9 100644 --- a/includes/specials/SpecialBooksources.php +++ b/includes/specials/SpecialBooksources.php @@ -125,6 +125,7 @@ class SpecialBookSources extends SpecialPage { $form .= ' ' . Xml::submitButton( $this->msg( 'booksources-go' )->text() ) . "

\n"; $form .= Html::closeElement( 'form' ) . "\n"; $form .= Html::closeElement( 'fieldset' ) . "\n"; + return $form; } diff --git a/includes/specials/SpecialChangePassword.php b/includes/specials/SpecialChangePassword.php index 2bd14c7dcc..0356d45b73 100644 --- a/includes/specials/SpecialChangePassword.php +++ b/includes/specials/SpecialChangePassword.php @@ -167,6 +167,7 @@ class SpecialChangePassword extends FormSpecialPage { } $query = $request->getVal( 'returntoquery' ); $this->getOutput()->redirect( $titleObj->getFullURL( $query ) ); + return true; } diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 3642750133..3acf141176 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -26,7 +26,6 @@ * * @ingroup SpecialPage */ - class SpecialContributions extends IncludableSpecialPage { protected $opts; @@ -66,6 +65,7 @@ class SpecialContributions extends IncludableSpecialPage { if ( !$this->including() ) { $out->addHTML( $this->getForm() ); } + return; } diff --git a/includes/specials/SpecialCreateAccount.php b/includes/specials/SpecialCreateAccount.php index 63d4ec9ee8..d781e6dc70 100644 --- a/includes/specials/SpecialCreateAccount.php +++ b/includes/specials/SpecialCreateAccount.php @@ -27,7 +27,6 @@ * * @ingroup SpecialPage */ - class SpecialCreateAccount extends SpecialRedirectToSpecial { function __construct() { parent::__construct( 'CreateAccount', 'Userlogin', 'signup', array( 'returnto', 'returntoquery', 'uselang' ) ); diff --git a/includes/specials/SpecialDeletedContributions.php b/includes/specials/SpecialDeletedContributions.php index 6c3cb952e4..31152154dd 100644 --- a/includes/specials/SpecialDeletedContributions.php +++ b/includes/specials/SpecialDeletedContributions.php @@ -276,7 +276,7 @@ class DeletedContribsPager extends IndexPager { class DeletedContributionsPage extends SpecialPage { function __construct() { parent::__construct( 'DeletedContributions', 'deletedhistory', - /*listed*/true, /*function*/false, /*file*/false ); + /*listed*/true, /*function*/false, /*file*/false ); } /** diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 98d5feadea..68e8703f6d 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -162,14 +162,14 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { } if ( count( $toWatch ) > 0 ) { - $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-added' - )->numParams( count( $toWatch ) )->parse(); + $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-added' ) + ->numParams( count( $toWatch ) )->parse(); $this->showTitles( $toWatch, $this->successMessage ); } if ( count( $toUnwatch ) > 0 ) { - $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' - )->numParams( count( $toUnwatch ) )->parse(); + $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' ) + ->numParams( count( $toUnwatch ) )->parse(); $this->showTitles( $toUnwatch, $this->successMessage ); } } else { diff --git a/includes/specials/SpecialExpandTemplates.php b/includes/specials/SpecialExpandTemplates.php index 7241105561..61925cf2ff 100644 --- a/includes/specials/SpecialExpandTemplates.php +++ b/includes/specials/SpecialExpandTemplates.php @@ -125,9 +125,7 @@ class SpecialExpandTemplates extends SpecialPage { } $this->showHtmlPreview( $title, $rawhtml, $out ); - } - } /** diff --git a/includes/specials/SpecialFilepath.php b/includes/specials/SpecialFilepath.php index e7ced52aa2..eb1c139c61 100644 --- a/includes/specials/SpecialFilepath.php +++ b/includes/specials/SpecialFilepath.php @@ -36,6 +36,7 @@ class SpecialFilepath extends RedirectSpecialPage { // implement by redirecting through Special:Redirect/file function getRedirect( $par ) { $file = $par ?: $this->getRequest()->getText( 'file' ); + return SpecialPage::getSafeTitleFor( 'Redirect', 'file/' . $file ); } diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index ba3e73f7cb..9f0d127c4b 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -129,7 +129,7 @@ class ImageListPager extends TablePager { $conds = array(); if ( !is_null( $this->mUserName ) ) { - $conds[ $prefix . '_user_text' ] = $this->mUserName; + $conds[$prefix . '_user_text'] = $this->mUserName; } if ( $this->mSearch !== '' ) { @@ -215,6 +215,7 @@ class ImageListPager extends TablePager { // for two different tables, without reimplementing // the pager class. $qi = $this->getQueryInfoReal( $this->mTableName ); + return $qi; } @@ -338,7 +339,7 @@ class ImageListPager extends TablePager { $topRes2 = $res2->next(); $resultArray = array(); for ( $i = 0; $i < $limit && $topRes1 && $topRes2; $i++ ) { - if ( strcmp( $topRes1->{ $this->mIndexField }, $topRes2->{ $this->mIndexField } ) > 0 ) { + if ( strcmp( $topRes1->{$this->mIndexField}, $topRes2->{$this->mIndexField} ) > 0 ) { if ( !$ascending ) { $resultArray[] = $topRes1; $topRes1 = $res1->next(); @@ -364,6 +365,7 @@ class ImageListPager extends TablePager { $resultArray[] = $topRes2; $topRes2 = $res2->next(); } + return new FakeResultWrapper( $resultArray ); } @@ -409,6 +411,7 @@ class ImageListPager extends TablePager { // If statement for paranoia if ( $file ) { $thumb = $file->transform( array( 'width' => 180, 'height' => 360 ) ); + return $thumb->toHtml( array( 'desc-link' => true ) ); } else { return htmlspecialchars( $value ); @@ -493,6 +496,7 @@ class ImageListPager extends TablePager { 'checked' => $this->mShowAll, 'tabindex' => 4, ) ); + return Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) ) . diff --git a/includes/specials/SpecialMIMEsearch.php b/includes/specials/SpecialMIMEsearch.php index dd78c4c6b2..50af9159d9 100644 --- a/includes/specials/SpecialMIMEsearch.php +++ b/includes/specials/SpecialMIMEsearch.php @@ -84,6 +84,7 @@ class MIMEsearchPage extends QueryPage { ), ), ); + return $qi; } diff --git a/includes/specials/SpecialMostrevisions.php b/includes/specials/SpecialMostrevisions.php index ad6b788d2c..0471cafe2d 100644 --- a/includes/specials/SpecialMostrevisions.php +++ b/includes/specials/SpecialMostrevisions.php @@ -23,6 +23,7 @@ * @ingroup SpecialPage * @author Ævar Arnfjörð Bjarmason */ + class MostrevisionsPage extends FewestrevisionsPage { function __construct( $name = 'Mostrevisions' ) { parent::__construct( $name ); diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index c054ef7042..91ef797326 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -593,8 +593,8 @@ class MovePageForm extends UnlistedSpecialPage { $dbr = wfGetDB( DB_MASTER ); if ( $this->moveSubpages && ( MWNamespace::hasSubpages( $nt->getNamespace() ) || ( - $this->moveTalk && - MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) + $this->moveTalk + && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) ) ) ) { $conds = array( diff --git a/includes/specials/SpecialMyRedirectPages.php b/includes/specials/SpecialMyRedirectPages.php index 41119f96ca..9b8d52bb32 100644 --- a/includes/specials/SpecialMyRedirectPages.php +++ b/includes/specials/SpecialMyRedirectPages.php @@ -108,6 +108,7 @@ class SpecialAllMyUploads extends RedirectSpecialPage { function getRedirect( $subpage ) { $this->mAddedRedirectParams['ilshowall'] = 1; + return SpecialPage::getTitleFor( 'Listfiles', $this->getUser()->getName() ); } } diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index 37d29734a0..c10a618b09 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -20,6 +20,7 @@ * @file * @ingroup SpecialPage */ + class SpecialNewFiles extends IncludableSpecialPage { public function __construct() { parent::__construct( 'Newimages' ); diff --git a/includes/specials/SpecialPermanentLink.php b/includes/specials/SpecialPermanentLink.php index 6c2ffe906d..17115e8863 100644 --- a/includes/specials/SpecialPermanentLink.php +++ b/includes/specials/SpecialPermanentLink.php @@ -39,6 +39,7 @@ class SpecialPermanentLink extends RedirectSpecialPage { throw new ErrorPageError( 'nopagetitle', 'nopagetext' ); } $this->mAddedRedirectParams['oldid'] = $subpage; + return true; } } diff --git a/includes/specials/SpecialRandomInCategory.php b/includes/specials/SpecialRandomInCategory.php index 4e2f0e72d5..e877b4e39f 100644 --- a/includes/specials/SpecialRandomInCategory.php +++ b/includes/specials/SpecialRandomInCategory.php @@ -207,6 +207,7 @@ class SpecialRandomInCategory extends SpecialPage { $qi['conds'][] = 'cl_timestamp ' . $op . ' ' . $dbr->addQuotes( $dbr->timestamp( $minClTime ) ); } + return $qi; } @@ -229,6 +230,7 @@ class SpecialRandomInCategory extends SpecialPage { } $ts = ( $this->maxTimestamp - $this->minTimestamp ) * $rand + $this->minTimestamp; + return intval( $ts ); } @@ -258,6 +260,7 @@ class SpecialRandomInCategory extends SpecialPage { if ( !$res ) { throw new MWException( 'No entries in category' ); } + return array( wfTimestamp( TS_UNIX, $res->low ), wfTimestamp( TS_UNIX, $res->high ) ); } diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 720d0a80f8..2c563c6199 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -45,6 +45,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $query = $this->getFeedQuery(); $query['feedformat'] = $feedFormat === 'atom' ? 'atom' : 'rss'; $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) ); + return; } @@ -272,6 +273,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { if ( $query['limit'] > $wgFeedLimit ) { $query['limit'] = $wgFeedLimit; } + return $query; } @@ -492,6 +494,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { public function checkLastModified() { $dbr = $this->getDB(); $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ ); + return $lastmod; } diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index c4f40befec..526e949a35 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -38,6 +38,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { $opts = parent::getDefaultOptions(); $opts->add( 'target', '' ); $opts->add( 'showlinkedto', false ); + return $opts; } @@ -58,6 +59,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { if ( !$title || $title->isExternal() ) { $outputPage->addHtml( '
' . $this->msg( 'allpagesbadtitle' ) ->parse() . '
' ); + return false; } @@ -91,7 +93,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { 'wl_user' => $uid, 'wl_title=rc_title', 'wl_namespace=rc_namespace' - )); + ) ); } if ( $this->getUser()->isAllowed( 'rollback' ) ) { $tables[] = 'page'; @@ -256,6 +258,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { $this->rclTargetTitle = false; } } + return $this->rclTargetTitle; } } diff --git a/includes/specials/SpecialRedirect.php b/includes/specials/SpecialRedirect.php index 8ec6f850fb..4926d6dd18 100644 --- a/includes/specials/SpecialRedirect.php +++ b/includes/specials/SpecialRedirect.php @@ -78,6 +78,7 @@ class SpecialRedirect extends FormSpecialPage { return null; } $userpage = Title::makeTitle( NS_USER, $username ); + return $userpage->getFullURL( '', false, PROTO_CURRENT ); } @@ -89,7 +90,7 @@ class SpecialRedirect extends FormSpecialPage { function dispatchFile() { $title = Title::makeTitleSafe( NS_FILE, $this->mValue ); - if ( ! $title instanceof Title ) { + if ( !$title instanceof Title ) { return null; } $file = wfFindFile( $title ); @@ -112,6 +113,7 @@ class SpecialRedirect extends FormSpecialPage { $url = $mto->getURL(); } } + return $url; } @@ -130,6 +132,7 @@ class SpecialRedirect extends FormSpecialPage { if ( $oldid === 0 ) { return null; } + return wfAppendQuery( wfScript( 'index' ), array( 'oldid' => $oldid ) ); @@ -149,6 +152,7 @@ class SpecialRedirect extends FormSpecialPage { if ( $curid === 0 ) { return null; } + return wfAppendQuery( wfScript( 'index' ), array( 'curid' => $curid ) ); @@ -165,33 +169,36 @@ class SpecialRedirect extends FormSpecialPage { function dispatch() { // the various namespaces supported by Special:Redirect switch ( $this->mType ) { - case 'user': - $url = $this->dispatchUser(); - break; - case 'file': - $url = $this->dispatchFile(); - break; - case 'revision': - $url = $this->dispatchRevision(); - break; - case 'page': - $url = $this->dispatchPage(); - break; - default: - $this->getOutput()->setStatusCode( 404 ); - $url = null; - break; + case 'user': + $url = $this->dispatchUser(); + break; + case 'file': + $url = $this->dispatchFile(); + break; + case 'revision': + $url = $this->dispatchRevision(); + break; + case 'page': + $url = $this->dispatchPage(); + break; + default: + $this->getOutput()->setStatusCode( 404 ); + $url = null; + break; } if ( $url ) { $this->getOutput()->redirect( $url ); + return true; } if ( !is_null( $this->mValue ) ) { $this->getOutput()->setStatusCode( 404 ); // Message: redirect-not-exists $msg = $this->getMessagePrefix() . '-not-exists'; + return Status::newFatal( $msg ); } + return false; } @@ -228,6 +235,7 @@ class SpecialRedirect extends FormSpecialPage { if ( !empty( $this->mValue ) ) { $a['value']['default'] = $this->mValue; } + return $a; } @@ -235,6 +243,7 @@ class SpecialRedirect extends FormSpecialPage { if ( !empty( $data['type'] ) && !empty( $data['value'] ) ) { $this->setParameter( $data['type'] . '/' . $data['value'] ); } + /* if this returns false, will show the form */ return $this->dispatch(); } diff --git a/includes/specials/SpecialResetTokens.php b/includes/specials/SpecialResetTokens.php index db98beaeed..864485ce5c 100644 --- a/includes/specials/SpecialResetTokens.php +++ b/includes/specials/SpecialResetTokens.php @@ -90,7 +90,7 @@ class SpecialResetTokens extends FormSpecialPage { ->rawParams( $this->msg( $tok['label-message'] )->parse() ) ->params( $user->getTokenFromOption( $tok['preference'] ) ) ->escaped(); - $tokensForForm[ $label ] = $tok['preference']; + $tokensForForm[$label] = $tok['preference']; } $desc = array( diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 05c8872e5f..780da7c73d 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -137,6 +137,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->token = $request->getVal( 'token' ); if ( $this->archiveName && $this->targetObj ) { $this->tryShowFile( $this->archiveName ); + return; } @@ -156,6 +157,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { # We need a target page! if ( is_null( $this->targetObj ) ) { $output->addWikiMsg( 'undelete-header' ); + return; } # Give a link to the logs/hist for this page @@ -257,6 +259,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $conds['log_action'] = $this->getList()->getLogAction(); $conds['ls_field'] = RevisionDeleter::getRelationType( $this->typeName ); $conds['ls_value'] = $this->ids; + return $conds; } @@ -271,6 +274,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { // Check if user is allowed to see this file if ( !$oimage->exists() ) { $this->getOutput()->addWikiMsg( 'revdelete-no-file' ); + return; } $user = $this->getUser(); @@ -300,6 +304,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { Xml::submitButton( $this->msg( 'revdelete-show-file-submit' )->text() ) . '' ); + return; } $this->getOutput()->disable(); @@ -325,6 +330,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->typeName, $this->getContext(), $this->targetObj, $this->ids ); } + return $this->list; } @@ -467,8 +473,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML ); $html .= "$line\n"; } - // Otherwise, use tri-state radios } else { + // Otherwise, use tri-state radios $html .= ''; $html .= '' . $this->msg( 'revdelete-radio-same' )->escaped() . ''; $html .= '' . $this->msg( 'revdelete-radio-unset' )->escaped() . ''; @@ -495,6 +501,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { } $html .= ''; + return $html; } @@ -508,6 +515,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $token = $this->getRequest()->getVal( 'wpEditToken' ); if ( $this->submitClicked && !$this->getUser()->matchEditToken( $token ) ) { $this->getOutput()->addWikiMsg( 'sessionfailure' ); + return false; } $bitParams = $this->extractBitParams(); @@ -527,11 +535,13 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $status = $this->save( $bitParams, $comment, $this->targetObj ); if ( $status->isGood() ) { $this->success(); + return true; - # ...otherwise, bounce back to form... } else { + # ...otherwise, bounce back to form... $this->failure( $status ); } + return false; } @@ -573,6 +583,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { if ( !isset( $bitfield[Revision::DELETED_RESTRICTED] ) ) { $bitfield[Revision::DELETED_RESTRICTED] = 0; } + return $bitfield; } diff --git a/includes/specials/SpecialRunJobs.php b/includes/specials/SpecialRunJobs.php index ab2b16edea..0c4528182e 100644 --- a/includes/specials/SpecialRunJobs.php +++ b/includes/specials/SpecialRunJobs.php @@ -38,10 +38,12 @@ class SpecialRunJobs extends UnlistedSpecialPage { if ( wfReadOnly() ) { header( "HTTP/1.0 423 Locked" ); print 'Wiki is in read-only mode'; + return; } elseif ( !$this->getRequest()->wasPosted() ) { header( "HTTP/1.0 400 Bad Request" ); print 'Request must be POSTed'; + return; } @@ -53,6 +55,7 @@ class SpecialRunJobs extends UnlistedSpecialPage { if ( count( $missing ) ) { header( "HTTP/1.0 400 Bad Request" ); print 'Missing parameters: ' . implode( ', ', array_keys( $missing ) ); + return; } @@ -76,6 +79,7 @@ class SpecialRunJobs extends UnlistedSpecialPage { if ( !$verified || $params['sigexpiry'] < time() ) { header( "HTTP/1.0 400 Bad Request" ); print 'Invalid or stale signature provided'; + return; } @@ -132,7 +136,7 @@ class SpecialRunJobs extends UnlistedSpecialPage { $job = $group->pop( JobQueueGroup::TYPE_DEFAULT, JobQueueGroup::USE_CACHE ); if ( $job ) { $output = $job->toString() . "\n"; - $t = - microtime( true ); + $t = -microtime( true ); wfProfileIn( __METHOD__ . '-' . get_class( $job ) ); $success = $job->run(); wfProfileOut( __METHOD__ . '-' . get_class( $job ) ); diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index aa38e6cd63..b481930926 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -179,6 +179,7 @@ class SpecialSearch extends SpecialPage { # If the string cannot be used to create a title if ( is_null( $t ) ) { $this->showResults( $term ); + return; } # If there's an exact or very near match, jump right there. @@ -191,6 +192,7 @@ class SpecialSearch extends SpecialPage { if ( !is_null( $t ) ) { $this->getOutput()->redirect( $t->getFullURL() ); + return; } # No match, generate an edit URL @@ -203,6 +205,7 @@ class SpecialSearch extends SpecialPage { # If the feature is enabled, go straight to the edit page if ( $wgGoToEdit ) { $this->getOutput()->redirect( $t->getFullURL( array( 'action' => 'edit' ) ) ); + return; } } @@ -247,6 +250,7 @@ class SpecialSearch extends SpecialPage { Xml::closeElement( 'fieldset' ) ); } + return; } @@ -328,6 +332,7 @@ class SpecialSearch extends SpecialPage { // Sometimes the search engine knows there are too many hits if ( $titleMatches instanceof SearchResultTooMany ) { $out->wrapWikiMsg( "==$1==\n", 'toomanymatches' ); + return; } @@ -336,6 +341,7 @@ class SpecialSearch extends SpecialPage { $out->addHTML( $this->formHeader( $term, 0, 0 ) ); $out->addHtml( $this->getProfileForm( $this->profile, $term ) ); $out->addHTML( '' ); + // Empty query -- straight view of search form return; } @@ -438,12 +444,14 @@ class SpecialSearch extends SpecialPage { // show direct page/create link if applicable // Check DBkey !== '' in case of fragment link only. - if ( is_null( $t ) || $t->getDBkey() === '' || - ( $titleMatches !== null && $titleMatches->searchContainedSyntax() ) || - ( $textMatches !== null && $textMatches->searchContainedSyntax() ) ) { + if ( is_null( $t ) || $t->getDBkey() === '' + || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() ) + || ( $textMatches !== null && $textMatches->searchContainedSyntax() ) + ) { // invalid title // preserve the paragraph for margins etc... $this->getOutput()->addHtml( '

' ); + return; } @@ -517,6 +525,7 @@ class SpecialSearch extends SpecialPage { $opt['ns' . $n] = 1; } } + return $opt + $this->extraParams; } @@ -573,7 +582,7 @@ class SpecialSearch extends SpecialPage { $link_t = clone $t; wfRunHooks( 'ShowSearchHitTitle', - array( &$link_t, &$titleSnippet, $result, $terms, $this ) ); + array( &$link_t, &$titleSnippet, $result, $terms, $this ) ); $link = Linker::linkKnown( $link_t, @@ -845,6 +854,7 @@ class SpecialSearch extends SpecialPage { } $out .= "
  • {$link} {$redirect}
  • \n"; + return $out; } @@ -864,6 +874,7 @@ class SpecialSearch extends SpecialPage { } else { $form = ''; wfRunHooks( 'SpecialSearchProfileForm', array( $this, &$form, $profile, $term, $opts ) ); + return $form; } } @@ -938,11 +949,12 @@ class SpecialSearch extends SpecialPage { foreach ( $opts as $key => $value ) { $hidden .= Html::hidden( $key, $value ); } + // Return final output return Xml::openElement( - 'fieldset', - array( 'id' => 'mw-searchoptions', 'style' => 'margin:0em;' ) - ) . + 'fieldset', + array( 'id' => 'mw-searchoptions', 'style' => 'margin:0em;' ) + ) . Xml::element( 'legend', null, $this->msg( 'powersearch-legend' )->text() ) . Xml::tags( 'h4', null, $this->msg( 'powersearch-ns' )->parse() ) . Html::element( 'div', array( 'id' => 'mw-search-togglebox' ) ) . @@ -1098,6 +1110,7 @@ class SpecialSearch extends SpecialPage { $this->msg( 'searchbutton' )->text(), array( 'class' => array( 'mw-ui-button', 'mw-ui-progressive' ) ) ) . "\n"; + return $out . $this->didYouMeanHtml; } @@ -1149,6 +1162,7 @@ class SpecialSearch extends SpecialPage { if ( count( $p ) > 1 ) { return $wgContLang->getNsIndex( $p[0] ) == NS_FILE; } + return false; } @@ -1166,6 +1180,7 @@ class SpecialSearch extends SpecialPage { if ( count( $p ) > 1 ) { return $p[0] == $allkeyword; } + return false; } @@ -1179,6 +1194,7 @@ class SpecialSearch extends SpecialPage { $this->searchEngine = $this->searchEngineType ? SearchEngine::create( $this->searchEngineType ) : SearchEngine::create(); } + return $this->searchEngine; } diff --git a/includes/specials/SpecialShortpages.php b/includes/specials/SpecialShortpages.php index 9b50875a3b..dffa7de758 100644 --- a/includes/specials/SpecialShortpages.php +++ b/includes/specials/SpecialShortpages.php @@ -40,12 +40,15 @@ class ShortPagesPage extends QueryPage { function getQueryInfo() { return array( 'tables' => array( 'page' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_len' ), - 'conds' => array( 'page_namespace' => - MWNamespace::getContentNamespaces(), - 'page_is_redirect' => 0 ), + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'page_len' + ), + 'conds' => array( + 'page_namespace' => MWNamespace::getContentNamespaces(), + 'page_is_redirect' => 0 + ), 'options' => array( 'USE INDEX' => 'page_redirect_namespace_len' ) ); } @@ -111,8 +114,8 @@ class ShortPagesPage extends QueryPage { $size = $this->msg( 'nbytes' )->numParams( $result->value )->escaped(); return $exists - ? "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]" - : "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]"; + ? "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]" + : "${hlinkInParentheses} {$dm}{$plink} {$dm}[{$size}]"; } protected function getGroupName() { diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index 56f3f415cd..c3a11f3e7a 100644 --- a/includes/specials/SpecialStatistics.php +++ b/includes/specials/SpecialStatistics.php @@ -30,7 +30,7 @@ class SpecialStatistics extends SpecialPage { private $views, $edits, $good, $images, $total, $users, - $activeUsers = 0; + $activeUsers = 0; public function __construct() { parent::__construct( 'Statistics' ); @@ -123,6 +123,7 @@ class SpecialStatistics extends SpecialPage { " $descriptionText" ); } } + return Html::rawElement( 'tr', $trExtraParams, Html::rawElement( 'td', array(), $text ) . Html::rawElement( 'td', array( 'class' => 'mw-statistics-numbers' ), $number ) @@ -166,6 +167,7 @@ class SpecialStatistics extends SpecialPage { private function getUserStats() { global $wgActiveUserDays; + return Xml::openElement( 'tr' ) . Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-users' )->parse() ) . Xml::closeElement( 'tr' ) . @@ -225,6 +227,7 @@ class SpecialStatistics extends SpecialPage { $this->getLanguage()->formatNum( $countUsers ), array( 'class' => 'statistics-group-' . Sanitizer::escapeClass( $group ) . $classZero ) ); } + return $text; } @@ -245,36 +248,39 @@ class SpecialStatistics extends SpecialPage { $text = ''; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( - 'page', - array( - 'page_namespace', - 'page_title', - 'page_counter', - ), - array( - 'page_is_redirect' => 0, - 'page_counter > 0', - ), - __METHOD__, - array( - 'ORDER BY' => 'page_counter DESC', - 'LIMIT' => 10, - ) - ); - if ( $res->numRows() > 0 ) { - $text .= Xml::openElement( 'tr' ); - $text .= Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-mostpopular' )->parse() ); - $text .= Xml::closeElement( 'tr' ); - foreach ( $res as $row ) { - $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); - if ( $title instanceof Title ) { - $text .= $this->formatRow( Linker::link( $title ), - $this->getLanguage()->formatNum( $row->page_counter ) ); - - } + 'page', + array( + 'page_namespace', + 'page_title', + 'page_counter', + ), + array( + 'page_is_redirect' => 0, + 'page_counter > 0', + ), + __METHOD__, + array( + 'ORDER BY' => 'page_counter DESC', + 'LIMIT' => 10, + ) + ); + + if ( $res->numRows() > 0 ) { + $text .= Xml::openElement( 'tr' ); + $text .= Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-mostpopular' )->parse() ); + $text .= Xml::closeElement( 'tr' ); + + foreach ( $res as $row ) { + $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); + + if ( $title instanceof Title ) { + $text .= $this->formatRow( Linker::link( $title ), + $this->getLanguage()->formatNum( $row->page_counter ) ); } - $res->free(); } + $res->free(); + } + return $text; } diff --git a/includes/specials/SpecialTags.php b/includes/specials/SpecialTags.php index 077e7cbcd8..b762728511 100644 --- a/includes/specials/SpecialTags.php +++ b/includes/specials/SpecialTags.php @@ -46,11 +46,11 @@ class SpecialTags extends SpecialPage { // Write the headers $html = Xml::tags( 'tr', null, Xml::tags( 'th', null, $this->msg( 'tags-tag' )->parse() ) . - Xml::tags( 'th', null, $this->msg( 'tags-display-header' )->parse() ) . - Xml::tags( 'th', null, $this->msg( 'tags-description-header' )->parse() ) . - Xml::tags( 'th', null, $this->msg( 'tags-active-header' )->parse() ) . - Xml::tags( 'th', null, $this->msg( 'tags-hitcount-header' )->parse() ) - ); + Xml::tags( 'th', null, $this->msg( 'tags-display-header' )->parse() ) . + Xml::tags( 'th', null, $this->msg( 'tags-description-header' )->parse() ) . + Xml::tags( 'th', null, $this->msg( 'tags-active-header' )->parse() ) . + Xml::tags( 'th', null, $this->msg( 'tags-hitcount-header' )->parse() ) + ); // Used in #doTagRow() $this->definedTags = array_fill_keys( ChangeTags::listDefinedTags(), true ); diff --git a/includes/specials/SpecialUnblock.php b/includes/specials/SpecialUnblock.php index fbc8e91636..3a2b0c6aea 100644 --- a/includes/specials/SpecialUnblock.php +++ b/includes/specials/SpecialUnblock.php @@ -107,7 +107,6 @@ class SpecialUnblock extends SpecialPage { if ( $type == Block::TYPE_AUTO && $this->type == Block::TYPE_IP ) { $fields['Target']['default'] = $this->target; unset( $fields['Name'] ); - } else { $fields['Target']['default'] = $target; $fields['Target']['type'] = 'hidden'; @@ -133,11 +132,11 @@ class SpecialUnblock extends SpecialPage { break; } } - } else { $fields['Target']['default'] = $this->target; unset( $fields['Name'] ); } + return $fields; } @@ -181,6 +180,7 @@ class SpecialUnblock extends SpecialPage { list( $target, $type ) = SpecialBlock::getTargetAndType( $target ); if ( $block->getType() == Block::TYPE_RANGE && $type == Block::TYPE_IP ) { $range = $block->getTarget(); + return array( array( 'ipb_blocked_as_range', $target, $range ) ); } diff --git a/includes/specials/SpecialUncategorizedimages.php b/includes/specials/SpecialUncategorizedimages.php index 3bfcedece3..17de679f26 100644 --- a/includes/specials/SpecialUncategorizedimages.php +++ b/includes/specials/SpecialUncategorizedimages.php @@ -50,13 +50,13 @@ class UncategorizedImagesPage extends ImageQueryPage { return array( 'tables' => array( 'page', 'categorylinks' ), 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_title' ), + 'title' => 'page_title', + 'value' => 'page_title' ), 'conds' => array( 'cl_from IS NULL', - 'page_namespace' => NS_FILE, - 'page_is_redirect' => 0 ), + 'page_namespace' => NS_FILE, + 'page_is_redirect' => 0 ), 'join_conds' => array( 'categorylinks' => array( - 'LEFT JOIN', 'cl_from=page_id' ) ) + 'LEFT JOIN', 'cl_from=page_id' ) ) ); } diff --git a/includes/specials/SpecialUncategorizedpages.php b/includes/specials/SpecialUncategorizedpages.php index 8bc9e489c2..c6a4215b6f 100644 --- a/includes/specials/SpecialUncategorizedpages.php +++ b/includes/specials/SpecialUncategorizedpages.php @@ -49,16 +49,21 @@ class UncategorizedPagesPage extends PageQueryPage { function getQueryInfo() { return array( 'tables' => array( 'page', 'categorylinks' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_title' ), + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'page_title' + ), // default for page_namespace is all content namespaces (if requestedNamespace is false) // otherwise, page_namespace is requestedNamespace - 'conds' => array( 'cl_from IS NULL', - 'page_namespace' => ( $this->requestedNamespace !== false ? $this->requestedNamespace : MWNamespace::getContentNamespaces() ), - 'page_is_redirect' => 0 ), - 'join_conds' => array( 'categorylinks' => array( - 'LEFT JOIN', 'cl_from = page_id' ) ) + 'conds' => array( + 'cl_from IS NULL', + 'page_namespace' => ( $this->requestedNamespace !== false ? $this->requestedNamespace : MWNamespace::getContentNamespaces() ), + 'page_is_redirect' => 0 + ), + 'join_conds' => array( + 'categorylinks' => array( 'LEFT JOIN', 'cl_from = page_id' ) + ) ); } @@ -68,6 +73,7 @@ class UncategorizedPagesPage extends PageQueryPage { if ( $this->requestedNamespace === false && count( MWNamespace::getContentNamespaces() ) > 1 ) { return array( 'page_namespace', 'page_title' ); } + return array( 'page_title' ); } diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 0dd5a0c4e0..acfeb37d23 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -58,6 +58,7 @@ class PageArchive { */ public static function listAllPages() { $dbr = wfGetDB( DB_SLAVE ); + return self::listPages( $dbr, '' ); } @@ -137,7 +138,7 @@ class PageArchive { } $conds = array( 'ar_namespace' => $this->title->getNamespace(), - 'ar_title' => $this->title->getDBkey() ); + 'ar_title' => $this->title->getDBkey() ); $options = array( 'ORDER BY' => 'ar_timestamp DESC' ); @@ -406,6 +407,7 @@ class PageArchive { ->inContentLanguage()->text(); } else { wfDebug( "Undelete: nothing undeleted...\n" ); + return false; } @@ -545,6 +547,7 @@ class PageArchive { $status = Status::newGood( 0 ); $status->warning( "undelete-no-results" ); + return $status; } @@ -765,6 +768,7 @@ class SpecialUndelete extends SpecialPage { if ( $user->isAllowed( 'browsearchive' ) ) { $this->showSearchForm(); } + return; } @@ -844,6 +848,7 @@ class SpecialUndelete extends SpecialPage { if ( $result->numRows() == 0 ) { $out->addWikiMsg( 'undelete-no-results' ); + return false; } @@ -897,6 +902,7 @@ class SpecialUndelete extends SpecialPage { if ( !$rev ) { $out->addWikiMsg( 'undeleterevision-missing' ); + return; } @@ -906,6 +912,7 @@ class SpecialUndelete extends SpecialPage { "\n", 'rev-deleted-text-permission' ); + return; } @@ -1269,32 +1276,31 @@ class SpecialUndelete extends SpecialPage { $unsuppressBox = ''; } - $table = - Xml::fieldset( $this->msg( 'undelete-fieldset-title' )->text() ) . - Xml::openElement( 'table', array( 'id' => 'mw-undelete-table' ) ) . - " - " . - $this->msg( 'undeleteextrahelp' )->parseAsBlock() . - " - - - " . - Xml::label( $this->msg( 'undeletecomment' )->text(), 'wpComment' ) . - " - " . - Xml::input( 'wpComment', 50, $this->mComment, array( 'id' => 'wpComment', 'autofocus' => true ) ) . - " - - -   - " . - Xml::submitButton( $this->msg( 'undeletebtn' )->text(), array( 'name' => 'restore', 'id' => 'mw-undelete-submit' ) ) . ' ' . - Xml::submitButton( $this->msg( 'undeleteinvert' )->text(), array( 'name' => 'invert', 'id' => 'mw-undelete-invert' ) ) . - " - " . - $unsuppressBox . - Xml::closeElement( 'table' ) . - Xml::closeElement( 'fieldset' ); + $table = Xml::fieldset( $this->msg( 'undelete-fieldset-title' )->text() ) . + Xml::openElement( 'table', array( 'id' => 'mw-undelete-table' ) ) . + " + " . + $this->msg( 'undeleteextrahelp' )->parseAsBlock() . + " + + + " . + Xml::label( $this->msg( 'undeletecomment' )->text(), 'wpComment' ) . + " + " . + Xml::input( 'wpComment', 50, $this->mComment, array( 'id' => 'wpComment', 'autofocus' => true ) ) . + " + + +   + " . + Xml::submitButton( $this->msg( 'undeletebtn' )->text(), array( 'name' => 'restore', 'id' => 'mw-undelete-submit' ) ) . ' ' . + Xml::submitButton( $this->msg( 'undeleteinvert' )->text(), array( 'name' => 'invert', 'id' => 'mw-undelete-invert' ) ) . + " + " . + $unsuppressBox . + Xml::closeElement( 'table' ) . + Xml::closeElement( 'fieldset' ); $out->addHTML( $table ); } diff --git a/includes/specials/SpecialUnusedcategories.php b/includes/specials/SpecialUnusedcategories.php index b686a5b5d2..c897332818 100644 --- a/includes/specials/SpecialUnusedcategories.php +++ b/includes/specials/SpecialUnusedcategories.php @@ -41,14 +41,17 @@ class UnusedCategoriesPage extends QueryPage { function getQueryInfo() { return array( 'tables' => array( 'page', 'categorylinks' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_title' ), - 'conds' => array( 'cl_from IS NULL', - 'page_namespace' => NS_CATEGORY, - 'page_is_redirect' => 0 ), - 'join_conds' => array( 'categorylinks' => array( - 'LEFT JOIN', 'cl_to = page_title' ) ) + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'page_title' + ), + 'conds' => array( + 'cl_from IS NULL', + 'page_namespace' => NS_CATEGORY, + 'page_is_redirect' => 0 + ), + 'join_conds' => array( 'categorylinks' => array( 'LEFT JOIN', 'cl_to = page_title' ) ) ); } @@ -67,6 +70,7 @@ class UnusedCategoriesPage extends QueryPage { */ function formatResult( $skin, $result ) { $title = Title::makeTitle( NS_CATEGORY, $result->title ); + return Linker::link( $title, htmlspecialchars( $title->getText() ) ); } diff --git a/includes/specials/SpecialUnusedimages.php b/includes/specials/SpecialUnusedimages.php index d332db7562..743c5878f1 100644 --- a/includes/specials/SpecialUnusedimages.php +++ b/includes/specials/SpecialUnusedimages.php @@ -47,28 +47,30 @@ class UnusedimagesPage extends ImageQueryPage { global $wgCountCategorizedImagesAsUsed; $retval = array( 'tables' => array( 'image', 'imagelinks' ), - 'fields' => array( 'namespace' => NS_FILE, - 'title' => 'img_name', - 'value' => 'img_timestamp', - 'img_user', 'img_user_text', - 'img_description' ), + 'fields' => array( + 'namespace' => NS_FILE, + 'title' => 'img_name', + 'value' => 'img_timestamp', + 'img_user', 'img_user_text', + 'img_description' + ), 'conds' => array( 'il_to IS NULL' ), - 'join_conds' => array( 'imagelinks' => array( - 'LEFT JOIN', 'il_to = img_name' ) ) + 'join_conds' => array( 'imagelinks' => array( 'LEFT JOIN', 'il_to = img_name' ) ) ); if ( $wgCountCategorizedImagesAsUsed ) { // Order is significant $retval['tables'] = array( 'image', 'page', 'categorylinks', - 'imagelinks' ); + 'imagelinks' ); $retval['conds']['page_namespace'] = NS_FILE; $retval['conds'][] = 'cl_from IS NULL'; $retval['conds'][] = 'img_name = page_title'; $retval['join_conds']['categorylinks'] = array( - 'LEFT JOIN', 'cl_from = page_id' ); + 'LEFT JOIN', 'cl_from = page_id' ); $retval['join_conds']['imagelinks'] = array( - 'LEFT JOIN', 'il_to = page_title' ); + 'LEFT JOIN', 'il_to = page_title' ); } + return $retval; } diff --git a/includes/specials/SpecialUnusedtemplates.php b/includes/specials/SpecialUnusedtemplates.php index 1dc9f420e9..f7e7a31338 100644 --- a/includes/specials/SpecialUnusedtemplates.php +++ b/includes/specials/SpecialUnusedtemplates.php @@ -50,12 +50,16 @@ class UnusedtemplatesPage extends QueryPage { function getQueryInfo() { return array( 'tables' => array( 'page', 'templatelinks' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_title' ), - 'conds' => array( 'page_namespace' => NS_TEMPLATE, - 'tl_from IS NULL', - 'page_is_redirect' => 0 ), + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'page_title' + ), + 'conds' => array( + 'page_namespace' => NS_TEMPLATE, + 'tl_from IS NULL', + 'page_is_redirect' => 0 + ), 'join_conds' => array( 'templatelinks' => array( 'LEFT JOIN', array( 'tl_title = page_title', 'tl_namespace = page_namespace' ) ) ) @@ -79,6 +83,7 @@ class UnusedtemplatesPage extends QueryPage { SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ), $this->msg( 'unusedtemplateswlh' )->escaped() ); + return $this->getLanguage()->specialList( $pageLink, $wlhLink ); } diff --git a/includes/specials/SpecialUnwatchedpages.php b/includes/specials/SpecialUnwatchedpages.php index 954e3ffe4c..ec2e7f558e 100644 --- a/includes/specials/SpecialUnwatchedpages.php +++ b/includes/specials/SpecialUnwatchedpages.php @@ -46,13 +46,16 @@ class UnwatchedpagesPage extends QueryPage { function getQueryInfo() { return array( 'tables' => array( 'page', 'watchlist' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_namespace' ), - 'conds' => array( 'wl_title IS NULL', - 'page_is_redirect' => 0, - "page_namespace != '" . NS_MEDIAWIKI . - "'" ), + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'page_namespace' + ), + 'conds' => array( + 'wl_title IS NULL', + 'page_is_redirect' => 0, + "page_namespace != '" . NS_MEDIAWIKI . "'" + ), 'join_conds' => array( 'watchlist' => array( 'LEFT JOIN', array( 'wl_title = page_title', 'wl_namespace = page_namespace' ) ) ) diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 35bbf0b58c..967050e446 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -179,6 +179,7 @@ class SpecialUpload extends SpecialPage { # Backwards compatibility hook if ( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) { wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" ); + return; } $this->showUploadForm( $this->getUploadForm() ); @@ -206,7 +207,6 @@ class SpecialUpload extends SpecialPage { } else { $this->getOutput()->addHTML( $form ); } - } /** @@ -401,6 +401,7 @@ class SpecialUpload extends SpecialPage { $status = $this->mUpload->fetchFile(); if ( !$status->isOK() ) { $this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) ); + return; } @@ -418,6 +419,7 @@ class SpecialUpload extends SpecialPage { $details = $this->mUpload->verifyUpload(); if ( $details['status'] != UploadBase::OK ) { $this->processVerificationError( $details ); + return; } @@ -426,6 +428,7 @@ class SpecialUpload extends SpecialPage { if ( $permErrors !== true ) { $code = array_shift( $permErrors[0] ); $this->showRecoverableUploadError( $this->msg( $code, $permErrors[0] )->parse() ); + return; } @@ -449,6 +452,7 @@ class SpecialUpload extends SpecialPage { $status = $this->mUpload->performUpload( $this->mComment, $pageText, $this->mWatchthis, $this->getUser() ); if ( !$status->isGood() ) { $this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) ); + return; } @@ -500,6 +504,7 @@ class SpecialUpload extends SpecialPage { $pageText = $comment; } } + return $pageText; } @@ -629,6 +634,7 @@ class SpecialUpload extends SpecialPage { $success = $this->mUpload->unsaveUploadedFile(); if ( !$success ) { $this->getOutput()->showFileDeleteError( $this->mUpload->getTempPath() ); + return false; } else { return true; @@ -707,6 +713,7 @@ class SpecialUpload extends SpecialPage { foreach ( $dupes as $file ) { $gallery->add( $file->getTitle() ); } + return '
  • ' . wfMessage( 'file-exists-duplicate' )->numParams( count( $dupes ) )->parse() . $gallery->toHtml() . "
  • \n"; @@ -741,8 +748,7 @@ class UploadForm extends HTMLForm { public function __construct( array $options = array(), IContextSource $context = null ) { $this->mWatch = !empty( $options['watch'] ); $this->mForReUpload = !empty( $options['forreupload'] ); - $this->mSessionKey = isset( $options['sessionkey'] ) - ? $options['sessionkey'] : ''; + $this->mSessionKey = isset( $options['sessionkey'] ) ? $options['sessionkey'] : ''; $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] ); $this->mDestWarningAck = !empty( $options['destwarningack'] ); $this->mDestFile = isset( $options['destfile'] ) ? $options['destfile'] : ''; @@ -778,7 +784,6 @@ class UploadForm extends HTMLForm { $this->mSourceIds[] = $field['id']; } } - } /** @@ -838,8 +843,8 @@ class UploadForm extends HTMLForm { 'upload-type' => 'File', 'radio' => &$radio, 'help' => $this->msg( 'upload-maxfilesize', - $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['file'] ) ) - ->parse() . + $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['file'] ) + )->parse() . $this->msg( 'word-separator' )->escaped() . $this->msg( 'upload_source_file' )->escaped(), 'checked' => $selectedSourceType == 'file', @@ -855,8 +860,8 @@ class UploadForm extends HTMLForm { 'upload-type' => 'url', 'radio' => &$radio, 'help' => $this->msg( 'upload-maxfilesize', - $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['url'] ) ) - ->parse() . + $this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['url'] ) + )->parse() . $this->msg( 'word-separator' )->escaped() . $this->msg( 'upload_source_url' )->escaped(), 'checked' => $selectedSourceType == 'url', @@ -870,6 +875,7 @@ class UploadForm extends HTMLForm { 'default' => $this->getExtensionsMessage(), 'raw' => true, ); + return $descriptor; } @@ -882,7 +888,7 @@ class UploadForm extends HTMLForm { # Print a list of allowed file extensions, if so configured. We ignore # MIME type here, it's incomprehensible to most people and too long. global $wgCheckFileExtensions, $wgStrictFileExtensions, - $wgFileExtensions, $wgFileBlacklist; + $wgFileExtensions, $wgFileBlacklist; if ( $wgCheckFileExtensions ) { if ( $wgStrictFileExtensions ) { @@ -905,6 +911,7 @@ class UploadForm extends HTMLForm { # Everything is permitted. $extensionsList = ''; } + return $extensionsList; } @@ -1100,7 +1107,6 @@ class UploadForm extends HTMLForm { function trySubmit() { return false; } - } /** @@ -1130,6 +1136,7 @@ class UploadSourceField extends HTMLTextField { $id = $this->mParams['id']; $label = Html::rawElement( 'label', array( 'for' => $id ), $this->mLabel ); } + return Html::rawElement( 'td', array( 'class' => 'mw-label' ) + $cellAttributes, $label ); } diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index 37bfa39bf8..16c348f1cf 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -66,6 +66,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { if ( $subPage === null || $subPage === '' ) { return $this->showUploads(); } + return $this->showUpload( $subPage ); } @@ -136,10 +137,11 @@ class SpecialUploadStash extends UnlistedSpecialPage { $handler = $file->getHandler(); if ( $handler ) { $params = $handler->parseParamString( $paramString ); + return array( 'file' => $file, 'type' => $type, 'params' => $params ); } else { throw new UploadStashBadPathException( 'No handler found for ' . - "mime {$file->getMimeType()} of file {$file->getPath()}" ); + "mime {$file->getMimeType()} of file {$file->getPath()}" ); } } @@ -204,7 +206,6 @@ class SpecialUploadStash extends UnlistedSpecialPage { } return $this->outputLocalFile( $thumbFile ); - } /** @@ -214,9 +215,9 @@ class SpecialUploadStash extends UnlistedSpecialPage { * Note: We rely on NFS to have propagated the file contents to the scaler. However, we do not rely on the thumbnail being created in NFS and then * propagated back to our filesystem. Instead we take the results of the HTTP request instead. * Note: no caching is being done here, although we are instructing the client to cache it forever. - * @param $file: File object - * @param $params: scaling parameters ( e.g. array( width => '50' ) ); - * @param $flags: scaling flags ( see File:: constants ) + * @param File $file + * @param array $params Scaling parameters ( e.g. array( width => '50' ) ); + * @param $flags Scaling flags ( see File:: constants ) * @throws MWException * @return boolean success */ @@ -248,16 +249,17 @@ class SpecialUploadStash extends UnlistedSpecialPage { ); $req = MWHttpRequest::factory( $scalerThumbUrl, $httpOptions ); $status = $req->execute(); - if ( ! $status->isOK() ) { + if ( !$status->isOK() ) { $errors = $status->getErrorsArray(); $errorStr = "Fetching thumbnail failed: " . print_r( $errors, 1 ); $errorStr .= "\nurl = $scalerThumbUrl\n"; throw new MWException( $errorStr ); } $contentType = $req->getResponseHeader( "content-type" ); - if ( ! $contentType ) { + if ( !$contentType ) { throw new MWException( "Missing content-type header" ); } + return $this->outputContents( $req->getContent(), $contentType ); } @@ -273,6 +275,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { if ( $file->getSize() > self::MAX_SERVE_BYTES ) { throw new SpecialUploadStashTooLargeException(); } + return $file->getRepo()->streamFile( $file->getPath(), array( 'Content-Transfer-Encoding: binary', 'Expires: Sun, 17-Jan-2038 19:14:07 GMT' ) @@ -294,6 +297,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { } self::outputFileHeaders( $contentType, $size ); print $content; + return true; } @@ -301,8 +305,8 @@ class SpecialUploadStash extends UnlistedSpecialPage { * Output headers for streaming * XXX unsure about encoding as binary; if we received from HTTP perhaps we should use that encoding, concatted with semicolon to mimeType as it usually is. * Side effect: preps PHP to write headers to STDOUT. - * @param string $contentType : string suitable for content-type header - * @param string $size: length in bytes + * @param string $contentType String suitable for content-type header + * @param string $size Length in bytes */ private static function outputFileHeaders( $contentType, $size ) { header( "Content-Type: $contentType", true ); @@ -325,10 +329,12 @@ class SpecialUploadStash extends UnlistedSpecialPage { if ( isset( $formData['Clear'] ) ) { $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash(); wfDebug( "stash has: " . print_r( $stash->listFiles(), true ) ); - if ( ! $stash->clear() ) { + + if ( !$stash->clear() ) { return Status::newFatal( 'uploadstash-errclear' ); } } + return Status::newGood(); } @@ -390,4 +396,6 @@ class SpecialUploadStash extends UnlistedSpecialPage { } } -class SpecialUploadStashTooLargeException extends MWException {}; +class SpecialUploadStashTooLargeException extends MWException { +} + diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 1c9fed7260..ec7bfa476d 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -101,7 +101,7 @@ class LoginForm extends SpecialPage { $this->mCookieCheck = $request->getVal( 'wpCookieCheck' ); $this->mPosted = $request->wasPosted(); $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' ) - && $wgEnableEmail; + && $wgEnableEmail; $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' ) && !$this->mCreateaccountMail; $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' ); $this->mAction = $request->getVal( 'action' ); @@ -134,9 +134,10 @@ class LoginForm extends SpecialPage { # 2. Do not return to PasswordReset after a successful password change # but goto Wiki start page (Main_Page) instead ( bug 33997 ) $returnToTitle = Title::newFromText( $this->mReturnTo ); - if ( is_object( $returnToTitle ) && ( - $returnToTitle->isSpecial( 'Userlogout' ) - || $returnToTitle->isSpecial( 'PasswordReset' ) ) ) { + if ( is_object( $returnToTitle ) + && ( $returnToTitle->isSpecial( 'Userlogout' ) + || $returnToTitle->isSpecial( 'PasswordReset' ) ) + ) { $this->mReturnTo = ''; $this->mReturnToQuery = ''; } @@ -183,6 +184,7 @@ class LoginForm extends SpecialPage { $this->getOutput()->redirect( $url ); // Since we only do this redir to change proto, always vary $this->getOutput()->addVaryHeader( 'X-Forwarded-Proto' ); + return; } else { // A wiki without HTTPS login support should set $wgServer to @@ -196,16 +198,20 @@ class LoginForm extends SpecialPage { if ( !is_null( $this->mCookieCheck ) ) { $this->onCookieRedirectCheck( $this->mCookieCheck ); + return; } elseif ( $this->mPosted ) { if ( $this->mCreateaccount ) { $this->addNewAccount(); + return; } elseif ( $this->mCreateaccountMail ) { $this->addNewAccountMailPassword(); + return; } elseif ( ( 'submitlogin' == $this->mAction ) || $this->mLoginattempt ) { $this->processLogin(); + return; } } @@ -218,6 +224,7 @@ class LoginForm extends SpecialPage { function addNewAccountMailPassword() { if ( $this->mEmail == '' ) { $this->mainLoginForm( $this->msg( 'noemailcreate' )->escaped() ); + return; } @@ -225,6 +232,7 @@ class LoginForm extends SpecialPage { if ( !$status->isGood() ) { $error = $status->getMessage(); $this->mainLoginForm( $error->toString() ); + return; } @@ -261,6 +269,7 @@ class LoginForm extends SpecialPage { if ( !$status->isGood() ) { $error = $status->getMessage(); $this->mainLoginForm( $error->toString() ); + return false; } @@ -324,6 +333,7 @@ class LoginForm extends SpecialPage { wfRunHooks( 'AddNewAccount', array( $u, false ) ); $u->addNewUserLogEntry( 'create2', $this->mReason ); } + return true; } @@ -366,6 +376,7 @@ class LoginForm extends SpecialPage { # Request forgery checks. if ( !self::getCreateaccountToken() ) { self::setCreateaccountToken(); + return Status::newFatal( 'nocookiesfornew' ); } @@ -387,6 +398,7 @@ class LoginForm extends SpecialPage { } elseif ( $creationBlock instanceof Block ) { // Throws an ErrorPageError. $this->userBlockedMessage( $creationBlock ); + // This should never be reached. return false; } @@ -394,7 +406,7 @@ class LoginForm extends SpecialPage { # Include checks that will include GlobalBlocking (Bug 38333) $permErrors = $this->getPageTitle()->getUserPermissionsErrors( 'createaccount', $currentUser, true ); if ( count( $permErrors ) ) { - throw new PermissionsError( 'createaccount', $permErrors ); + throw new PermissionsError( 'createaccount', $permErrors ); } $ip = $this->getRequest()->getIP(); @@ -432,6 +444,7 @@ class LoginForm extends SpecialPage { if ( !is_array( $valid ) ) { $valid = array( $valid, $wgMinimalPasswordLength ); } + return call_user_func_array( 'Status::newFatal', $valid ); } } @@ -463,6 +476,7 @@ class LoginForm extends SpecialPage { // To return a different error code, return a Status object. $abortError = new Message( 'createaccount-hook-aborted', array( $abortError ) ); $abortError->text(); + return Status::newFatal( $abortError ); } else { // For MediaWiki 1.23+ and updated hooks, return the Status object @@ -493,6 +507,7 @@ class LoginForm extends SpecialPage { } self::clearCreateaccountToken(); + return $this->initUser( $u, false ); } @@ -560,6 +575,7 @@ class LoginForm extends SpecialPage { // If the user doesn't have a login token yet, set one. if ( !self::getLoginToken() ) { self::setLoginToken(); + return self::NEED_TOKEN; } // If the user didn't pass a login token, tell them we need one @@ -585,6 +601,7 @@ class LoginForm extends SpecialPage { // will effectively be using stale data. if ( $this->getUser()->getName() === $this->mUsername ) { wfDebug( __METHOD__ . ": already logged in as {$this->mUsername}\n" ); + return self::SUCCESS; } @@ -610,6 +627,7 @@ class LoginForm extends SpecialPage { $msg = null; if ( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$msg ) ) ) { $this->mAbortLoginErrorMsg = $msg; + return $abort; } @@ -674,6 +692,7 @@ class LoginForm extends SpecialPage { $retval = self::SUCCESS; } wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword, $retval ) ); + return $retval; } @@ -732,17 +751,23 @@ class LoginForm extends SpecialPage { if ( $this->getUser()->isBlockedFromCreateAccount() ) { wfDebug( __METHOD__ . ": user is blocked from account creation\n" ); + return self::CREATE_BLOCKED; } + if ( !$wgAuth->autoCreate() ) { return self::NOT_EXISTS; } + if ( !$wgAuth->userExists( $user->getName() ) ) { wfDebug( __METHOD__ . ": user does not exist\n" ); + return self::NOT_EXISTS; } + if ( !$wgAuth->authenticate( $user->getName(), $this->mPassword ) ) { wfDebug( __METHOD__ . ": \$wgAuth->authenticate() returned false, aborting\n" ); + return self::WRONG_PLUGIN_PASS; } @@ -751,6 +776,7 @@ class LoginForm extends SpecialPage { // Hook point to add extra creation throttles and blocks wfDebug( "LoginForm::attemptAutoCreate: a hook blocked creation: $abortError\n" ); $this->mAbortLoginErrorMsg = $abortError; + return self::ABORTED; } @@ -760,6 +786,7 @@ class LoginForm extends SpecialPage { if ( !$status->isOK() ) { $errors = $status->getErrorsByType( 'error' ); $this->mAbortLoginErrorMsg = $errors[0]['message']; + return self::ABORTED; } @@ -768,7 +795,7 @@ class LoginForm extends SpecialPage { function processLogin() { global $wgMemc, $wgLang, $wgSecureLogin, $wgPasswordAttemptThrottle, - $wgInvalidPasswordReset; + $wgInvalidPasswordReset; switch ( $this->authenticateUserData() ) { case self::SUCCESS: @@ -870,8 +897,8 @@ class LoginForm extends SpecialPage { case self::THROTTLED: $error = $this->mAbortLoginErrorMsg ?: 'login-throttled'; $this->mainLoginForm( $this->msg( $error ) - ->params ( $this->getLanguage()->formatDuration( $wgPasswordAttemptThrottle['seconds'] ) ) - ->text() + ->params( $this->getLanguage()->formatDuration( $wgPasswordAttemptThrottle['seconds'] ) ) + ->text() ); break; case self::USER_BLOCKED: @@ -1133,6 +1160,7 @@ class LoginForm extends SpecialPage { throw new PermissionsError( 'createaccount', $permErrors ); } elseif ( $user->isBlockedFromCreateAccount() ) { $this->userBlockedMessage( $user->isBlockedFromCreateAccount() ); + return; } elseif ( wfReadOnly() ) { throw new ReadOnlyError; @@ -1324,6 +1352,7 @@ class LoginForm extends SpecialPage { */ function hasSessionCookie() { global $wgDisableCookieCheck; + return $wgDisableCookieCheck ? true : $this->getRequest()->checkSessionCookie(); } @@ -1333,6 +1362,7 @@ class LoginForm extends SpecialPage { */ public static function getLoginToken() { global $wgRequest; + return $wgRequest->getSessionData( 'wsLoginToken' ); } @@ -1360,6 +1390,7 @@ class LoginForm extends SpecialPage { */ public static function getCreateaccountToken() { global $wgRequest; + return $wgRequest->getSessionData( 'wsCreateaccountToken' ); } @@ -1442,6 +1473,7 @@ class LoginForm extends SpecialPage { $links[] = $this->makeLanguageSelectorLink( $parts[0], trim( $parts[1] ) ); } } + return count( $links ) > 0 ? $this->msg( 'loginlanguagelabel' )->rawParams( $this->getLanguage()->pipeList( $links ) )->escaped() : ''; } else { diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 3ef8f8b9b5..e0878f1667 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -55,6 +55,7 @@ class UserrightsPage extends SpecialPage { if ( $user->getId() == 0 ) { return false; } + return !empty( $available['add'] ) || !empty( $available['remove'] ) || ( ( $this->isself || !$checkIfSelf ) && @@ -118,6 +119,7 @@ class UserrightsPage extends SpecialPage { $out = $this->getOutput(); $out->wrapWikiMsg( "
    \n$1\n
    ", 'userrights-removed-self' ); $out->returnToMain(); + return; } @@ -148,6 +150,7 @@ class UserrightsPage extends SpecialPage { $status = $this->fetchUser( $this->mTarget ); if ( !$status->isOK() ) { $this->getOutput()->addWikiText( $status->getWikiText() ); + return; } @@ -166,6 +169,7 @@ class UserrightsPage extends SpecialPage { ); $out->redirect( $this->getSuccessURL() ); + return; } } @@ -266,6 +270,7 @@ class UserrightsPage extends SpecialPage { if ( $newGroups != $oldGroups ) { $this->addLogEntry( $user, $oldGroups, $newGroups, $reason ); } + return array( $add, $remove ); } @@ -293,6 +298,7 @@ class UserrightsPage extends SpecialPage { $status = $this->fetchUser( $username ); if ( !$status->isOK() ) { $this->getOutput()->addWikiText( $status->getWikiText() ); + return; } else { $user = $status->value; @@ -486,10 +492,10 @@ class UserrightsPage extends SpecialPage { } $userToolLinks = Linker::userToolLinks( - $user->getId(), - $user->getName(), - false, /* default for redContribsWhenNoEdits */ - Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */ + $user->getId(), + $user->getName(), + false, /* default for redContribsWhenNoEdits */ + Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */ ); $this->getOutput()->addHTML( @@ -640,6 +646,7 @@ class UserrightsPage extends SpecialPage { private function canRemove( $group ) { // $this->changeableGroups()['remove'] doesn't work, of course. Thanks, PHP. $groups = $this->changeableGroups(); + return in_array( $group, $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] ) ); } @@ -649,6 +656,7 @@ class UserrightsPage extends SpecialPage { */ private function canAdd( $group ) { $groups = $this->changeableGroups(); + return in_array( $group, $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] ) ); } diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index d509f218c1..98b30b7e47 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -255,6 +255,7 @@ class SpecialVersion extends SpecialPage { } wfProfileOut( __METHOD__ ); + return $version; } @@ -283,6 +284,7 @@ class SpecialVersion extends SpecialPage { } wfProfileOut( __METHOD__ ); + return $v; } @@ -323,6 +325,7 @@ class SpecialVersion extends SpecialPage { preg_match( "/^(\d+\.\d+)/", $wgVersion, $versionParts ); $versionUrl = "https://www.mediawiki.org/wiki/MediaWiki_{$versionParts[1]}"; } + return "[$versionUrl $wgVersion]"; } @@ -396,6 +399,7 @@ class SpecialVersion extends SpecialPage { */ public static function getExtensionTypeName( $type ) { $types = self::getExtensionTypes(); + return isset( $types[$type] ) ? $types[$type] : $types['other']; } @@ -469,7 +473,7 @@ class SpecialVersion extends SpecialPage { ) ); - array_walk( $tags, function( &$value ) { + array_walk( $tags, function ( &$value ) { $value = '<' . htmlentities( $value ) . '>'; } ); $out .= $this->listToText( $tags ); @@ -633,9 +637,9 @@ class SpecialVersion extends SpecialPage { if ( $vcsDate ) { $vcsTimeString = Html::element( 'span', - array( 'class' => 'mw-version-ext-vcs-timestamp' ), - $this->getLanguage()->timeanddate( $vcsDate ) - ); + array( 'class' => 'mw-version-ext-vcs-timestamp' ), + $this->getLanguage()->timeanddate( $vcsDate ) + ); $versionString .= " {$vcsTimeString}"; } $versionString = Html::rawElement( 'span', @@ -784,6 +788,7 @@ class SpecialVersion extends SpecialPage { */ private function IPInfo() { $ip = str_replace( '--', ' - ', htmlspecialchars( $this->getRequest()->getIP() ) ); + return "\nvisited from $ip"; } @@ -824,13 +829,11 @@ class SpecialVersion extends SpecialPage { $text = $this->msg( 'version-poweredby-others' )->text(); } $list[] = $text; - } elseif ( substr( $item, -5 ) == ' ...]' ) { $hasOthers = true; $list[] = $this->getOutput()->parseInline( substr( $item, 0, -4 ) . $this->msg( 'version-poweredby-others' )->text() . "]" ); - } else { $list[] = $this->getOutput()->parseInline( $item ); } @@ -850,7 +853,7 @@ class SpecialVersion extends SpecialPage { * Obtains the full path of an extensions authors or credits file if * one exists. * - * @param string $extDir: Path to the extensions root directory + * @param string $extDir Path to the extensions root directory * * @since 1.23 * @@ -879,7 +882,7 @@ class SpecialVersion extends SpecialPage { * Obtains the full path of an extensions copying or license file if * one exists. * - * @param string $extDir: Path to the extensions root directory + * @param string $extDir Path to the extensions root directory * * @since 1.23 * @@ -924,6 +927,7 @@ class SpecialVersion extends SpecialPage { if ( $sort ) { sort( $list ); } + return $this->getLanguage()->listToText( array_map( array( __CLASS__, 'arrayToString' ), $list ) ); } } @@ -942,6 +946,7 @@ class SpecialVersion extends SpecialPage { } if ( is_object( $list ) ) { $class = wfMessage( 'parentheses' )->params( get_class( $list ) )->escaped(); + return $class; } elseif ( !is_array( $list ) ) { return $list; @@ -951,6 +956,7 @@ class SpecialVersion extends SpecialPage { } else { $class = $list[0]; } + return wfMessage( 'parentheses' )->params( "$class, {$list[1]}" )->escaped(); } } @@ -1063,6 +1069,7 @@ class SpecialVersion extends SpecialPage { */ public static function getGitHeadSha1( $dir ) { $repo = new GitInfo( $dir ); + return $repo->getHeadSHA1(); } @@ -1111,11 +1118,11 @@ class SpecialVersion extends SpecialPage { } $out .= Html::closeElement( 'table' ); + return $out; } protected function getGroupName() { return 'wiki'; } - } diff --git a/includes/specials/SpecialWantedcategories.php b/includes/specials/SpecialWantedcategories.php index 51d9af3fa1..b8c0bb2820 100644 --- a/includes/specials/SpecialWantedcategories.php +++ b/includes/specials/SpecialWantedcategories.php @@ -38,9 +38,11 @@ class WantedCategoriesPage extends WantedQueryPage { function getQueryInfo() { return array( 'tables' => array( 'categorylinks', 'page' ), - 'fields' => array( 'namespace' => NS_CATEGORY, - 'title' => 'cl_to', - 'value' => 'COUNT(*)' ), + 'fields' => array( + 'namespace' => NS_CATEGORY, + 'title' => 'cl_to', + 'value' => 'COUNT(*)' + ), 'conds' => array( 'page_title IS NULL' ), 'options' => array( 'GROUP BY' => 'cl_to' ), 'join_conds' => array( 'page' => array( 'LEFT JOIN', @@ -73,7 +75,7 @@ class WantedCategoriesPage extends WantedQueryPage { __METHOD__ ); foreach ( $categoryRes as $row ) { - $this->currentCategoryCounts[ $row->cat_title ] = intval( $row->cat_pages ); + $this->currentCategoryCounts[$row->cat_title] = intval( $row->cat_pages ); } // Back to start for display @@ -104,8 +106,8 @@ class WantedCategoriesPage extends WantedQueryPage { } else { $plink = Linker::link( $nt, $text ); - $currentValue = isset( $this->currentCategoryCounts[ $result->title ] ) - ? $this->currentCategoryCounts[ $result->title ] + $currentValue = isset( $this->currentCategoryCounts[$result->title] ) + ? $this->currentCategoryCounts[$result->title] : 0; // If the category has been created or emptied since the list was refreshed, strike it diff --git a/includes/specials/SpecialWantedfiles.php b/includes/specials/SpecialWantedfiles.php index b5c1fdbeb7..fa68504b2a 100644 --- a/includes/specials/SpecialWantedfiles.php +++ b/includes/specials/SpecialWantedfiles.php @@ -75,9 +75,11 @@ class WantedFilesPage extends WantedQueryPage { function getQueryInfo() { return array( 'tables' => array( 'imagelinks', 'image' ), - 'fields' => array( 'namespace' => NS_FILE, - 'title' => 'il_to', - 'value' => 'COUNT(*)' ), + 'fields' => array( + 'namespace' => NS_FILE, + 'title' => 'il_to', + 'value' => 'COUNT(*)' + ), 'conds' => array( 'img_name IS NULL' ), 'options' => array( 'GROUP BY' => 'il_to' ), 'join_conds' => array( 'image' => diff --git a/includes/specials/SpecialWantedpages.php b/includes/specials/SpecialWantedpages.php index acec4ea455..c54d9f4399 100644 --- a/includes/specials/SpecialWantedpages.php +++ b/includes/specials/SpecialWantedpages.php @@ -69,8 +69,7 @@ class WantedPagesPage extends WantedQueryPage { ), 'conds' => array( 'pg1.page_namespace IS NULL', - "pl_namespace NOT IN ( '" . NS_USER . - "', '" . NS_USER_TALK . "' )", + "pl_namespace NOT IN ( '" . NS_USER . "', '" . NS_USER_TALK . "' )", "pg2.page_namespace != '" . NS_MEDIAWIKI . "'" ), 'options' => array( @@ -89,6 +88,7 @@ class WantedPagesPage extends WantedQueryPage { ); // Replacement for the WantedPages::getSQL hook wfRunHooks( 'WantedPages::getQueryInfo', array( &$this, &$query ) ); + return $query; } diff --git a/includes/specials/SpecialWantedtemplates.php b/includes/specials/SpecialWantedtemplates.php index d13fa0318b..550e2e35df 100644 --- a/includes/specials/SpecialWantedtemplates.php +++ b/includes/specials/SpecialWantedtemplates.php @@ -40,16 +40,19 @@ class WantedTemplatesPage extends WantedQueryPage { function getQueryInfo() { return array( 'tables' => array( 'templatelinks', 'page' ), - 'fields' => array( 'namespace' => 'tl_namespace', - 'title' => 'tl_title', - 'value' => 'COUNT(*)' ), - 'conds' => array( 'page_title IS NULL', - 'tl_namespace' => NS_TEMPLATE ), - 'options' => array( - 'GROUP BY' => array( 'tl_namespace', 'tl_title' ) ), + 'fields' => array( + 'namespace' => 'tl_namespace', + 'title' => 'tl_title', + 'value' => 'COUNT(*)' + ), + 'conds' => array( + 'page_title IS NULL', + 'tl_namespace' => NS_TEMPLATE + ), + 'options' => array( 'GROUP BY' => array( 'tl_namespace', 'tl_title' ) ), 'join_conds' => array( 'page' => array( 'LEFT JOIN', - array( 'page_namespace = tl_namespace', - 'page_title = tl_title' ) ) ) + array( 'page_namespace = tl_namespace', + 'page_title = tl_title' ) ) ) ); } diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 4c3f17bb98..68a514c8a4 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -58,6 +58,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { } $output->redirect( $title->getLocalURL() ); + return; } @@ -66,11 +67,13 @@ class SpecialWatchlist extends ChangesListSpecialPage { $user = $this->getUser(); $opts = $this->getOptions(); - if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) && - $request->wasPosted() ) - { + if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) + && $request->getVal( 'reset' ) + && $request->wasPosted() + ) { $user->clearAllNotifications(); $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) ); + return; } @@ -145,6 +148,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { // methods defined on WebRequest and removing this dependency would cause some code duplication. $request = new DerivativeRequest( $this->getRequest(), $params ); $opts->fetchValuesFromRequest( $request ); + return $opts; } @@ -379,7 +383,8 @@ class SpecialWatchlist extends ChangesListSpecialPage { if ( $opts['days'] > 0 ) { $timestamp = wfTimestampNow(); $wlInfo = $this->msg( 'wlnote2' )->numParams( round( $opts['days'] * 24 ) )->params( - $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->parse() . "
    \n"; + $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) + )->parse() . "
    \n"; } $nondefaults = $opts->getChangedValues(); @@ -557,6 +562,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { foreach ( $days as $d ) { $days[$i++] = $this->daysLink( $d, $options ); } + return $this->msg( 'wlshowlast' )->rawParams( $this->getLanguage()->pipeList( $hours ), $this->getLanguage()->pipeList( $days ), diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index 176fbd4f76..2e07309f45 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -79,6 +79,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $this->target = Title::newFromURL( $opts->getValue( 'target' ) ); if ( !$this->target ) { $out->addHTML( $this->whatlinkshereForm() ); + return; } @@ -158,7 +159,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { 'rd_namespace' => $target->getNamespace(), 'rd_title' => $target->getDBkey(), 'rd_interwiki = ' . $dbr->addQuotes( '' ) . ' OR rd_interwiki IS NULL' - ))); + ) ) ); if ( $fetchlinks ) { $options['ORDER BY'] = 'pl_from'; @@ -197,6 +198,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $out->addWikiMsg( $errMsg, $this->target->getPrefixedText() ); } } + return; } @@ -270,7 +272,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $out->addHTML( $this->listEnd() ); if ( $level == 0 ) { - if( !$this->including() ){ + if ( !$this->including() ) { $out->addHTML( $prevnext ); } } @@ -414,7 +416,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { # Target input $f .= Xml::inputLabel( $this->msg( 'whatlinkshere-page' )->text(), 'target', - 'mw-whatlinkshere-target', 40, $target ); + 'mw-whatlinkshere-target', 40, $target ); $f .= ' '; @@ -469,6 +471,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $links[] = $this->msg( "whatlinkshere-{$type}" )->rawParams( $this->makeSelfLink( $msg, array_merge( $changed, $overrides ) ) )->escaped(); } + return Xml::fieldset( $this->msg( 'whatlinkshere-filters' )->text(), $this->getLanguage()->pipeList( $links ) ); } diff --git a/includes/specials/SpecialWithoutinterwiki.php b/includes/specials/SpecialWithoutinterwiki.php index 2ddde4351b..edb1558645 100644 --- a/includes/specials/SpecialWithoutinterwiki.php +++ b/includes/specials/SpecialWithoutinterwiki.php @@ -80,19 +80,23 @@ class WithoutInterwikiPage extends PageQueryPage { function getQueryInfo() { $query = array( 'tables' => array( 'page', 'langlinks' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_title' ), - 'conds' => array( 'll_title IS NULL', - 'page_namespace' => MWNamespace::getContentNamespaces(), - 'page_is_redirect' => 0 ), - 'join_conds' => array( 'langlinks' => array( - 'LEFT JOIN', 'll_from = page_id' ) ) + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'page_title' + ), + 'conds' => array( + 'll_title IS NULL', + 'page_namespace' => MWNamespace::getContentNamespaces(), + 'page_is_redirect' => 0 + ), + 'join_conds' => array( 'langlinks' => array( 'LEFT JOIN', 'll_from = page_id' ) ) ); if ( $this->prefix ) { $dbr = wfGetDB( DB_SLAVE ); $query['conds'][] = 'page_title ' . $dbr->buildLike( $this->prefix, $dbr->anyString() ); } + return $query; } -- 2.20.1