From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- includes/specialpage/ChangesListSpecialPage.php | 18 +++++--- includes/specialpage/FormSpecialPage.php | 29 ++++++++----- includes/specialpage/ImageQueryPage.php | 4 +- includes/specialpage/PageQueryPage.php | 2 +- includes/specialpage/QueryPage.php | 17 +++----- includes/specialpage/RedirectSpecialPage.php | 2 +- includes/specialpage/SpecialPage.php | 55 +++++++++++++++++++++---- includes/specialpage/SpecialPageFactory.php | 40 ++++++++---------- includes/specialpage/WantedQueryPage.php | 4 +- 9 files changed, 109 insertions(+), 62 deletions(-) (limited to 'includes/specialpage') diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index c28aa867..b9132358 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -65,6 +65,12 @@ abstract class ChangesListSpecialPage extends SpecialPage { $batch->add( NS_USER, $row->rc_user_text ); $batch->add( NS_USER_TALK, $row->rc_user_text ); $batch->add( $row->rc_namespace, $row->rc_title ); + if ( $row->rc_source === RecentChange::SRC_LOG ) { + $formatter = LogFormatter::newFromRow( $row ); + foreach ( $formatter->getPreloadTitles() as $title ) { + $batch->addObj( $title ); + } + } } $batch->execute(); @@ -154,7 +160,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { protected function getCustomFilters() { if ( $this->customFilters === null ) { $this->customFilters = array(); - wfRunHooks( 'ChangesListSpecialPageFilters', array( $this, &$this->customFilters ) ); + Hooks::run( 'ChangesListSpecialPageFilters', array( $this, &$this->customFilters ) ); } return $this->customFilters; @@ -309,17 +315,19 @@ abstract class ChangesListSpecialPage extends SpecialPage { ); } - protected function runMainQueryHook( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) { - return wfRunHooks( + protected function runMainQueryHook( &$tables, &$fields, &$conds, + &$query_options, &$join_conds, $opts + ) { + return Hooks::run( 'ChangesListSpecialPageQuery', array( $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) ); } /** - * Return a DatabaseBase object for reading + * Return a IDatabase object for reading * - * @return DatabaseBase + * @return IDatabase */ protected function getDB() { return wfGetDB( DB_SLAVE ); diff --git a/includes/specialpage/FormSpecialPage.php b/includes/specialpage/FormSpecialPage.php index bf86ab2e..90567617 100644 --- a/includes/specialpage/FormSpecialPage.php +++ b/includes/specialpage/FormSpecialPage.php @@ -74,22 +74,29 @@ abstract class FormSpecialPage extends SpecialPage { return strtolower( $this->getName() ); } + /** + * Get display format for the form. See HTMLForm documentation for available values. + * + * @since 1.25 + * @return string + */ + protected function getDisplayFormat() { + return 'table'; + } + /** * Get the HTMLForm to control behavior * @return HTMLForm|null */ protected function getForm() { - $this->fields = $this->getFormFields(); - - $form = new HTMLForm( $this->fields, $this->getContext(), $this->getMessagePrefix() ); + $form = HTMLForm::factory( + $this->getDisplayFormat(), + $this->getFormFields(), + $this->getContext(), + $this->getMessagePrefix() + ); $form->setSubmitCallback( array( $this, 'onSubmit' ) ); - // If the form is a compact vertical form, then don't output this ugly - // fieldset surrounding it. - // XXX Special pages can setDisplayFormat to 'vform' in alterForm(), but that - // is called after this. - if ( !$form->isVForm() ) { - $form->setWrapperLegendMsg( $this->getMessagePrefix() . '-legend' ); - } + $form->setWrapperLegendMsg( $this->getMessagePrefix() . '-legend' ); $headerMsg = $this->msg( $this->getMessagePrefix() . '-text' ); if ( !$headerMsg->isDisabled() ) { @@ -106,7 +113,7 @@ abstract class FormSpecialPage extends SpecialPage { $this->alterForm( $form ); // Give hooks a chance to alter the form, adding extra fields or text etc - wfRunHooks( 'SpecialPageBeforeFormDisplay', array( $this->getName(), &$form ) ); + Hooks::run( 'SpecialPageBeforeFormDisplay', array( $this->getName(), &$form ) ); return $form; } diff --git a/includes/specialpage/ImageQueryPage.php b/includes/specialpage/ImageQueryPage.php index 272d5337..c4e53eef 100644 --- a/includes/specialpage/ImageQueryPage.php +++ b/includes/specialpage/ImageQueryPage.php @@ -35,7 +35,7 @@ abstract class ImageQueryPage extends QueryPage { * * @param OutputPage $out OutputPage to print to * @param Skin $skin User skin to use [unused] - * @param DatabaseBase $dbr (read) connection to use + * @param IDatabase $dbr (read) connection to use * @param ResultWrapper $res Result pointer * @param int $num Number of available result rows * @param int $offset Paging offset @@ -59,7 +59,7 @@ abstract class ImageQueryPage extends QueryPage { } } - $out->addHTML( $gallery->toHtml() ); + $out->addHTML( $gallery->toHTML() ); } } diff --git a/includes/specialpage/PageQueryPage.php b/includes/specialpage/PageQueryPage.php index afc02271..d72744b1 100644 --- a/includes/specialpage/PageQueryPage.php +++ b/includes/specialpage/PageQueryPage.php @@ -32,7 +32,7 @@ abstract class PageQueryPage extends QueryPage { * like page existence and information for stub color and redirect hints. * This should be done for live data and cached data. * - * @param DatabaseBase $db + * @param IDatabase $db * @param ResultWrapper $res */ public function preprocessResults( $db, $res ) { diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index b229e06e..1ff7e3fb 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -60,7 +60,6 @@ abstract class QueryPage extends SpecialPage { * @return array */ public static function getPages() { - global $wgDisableCounters; static $qp = null; if ( $qp === null ) { @@ -82,7 +81,7 @@ abstract class QueryPage extends SpecialPage { array( 'MostimagesPage', 'Mostimages' ), array( 'MostinterwikisPage', 'Mostinterwikis' ), array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ), - array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ), + array( 'MostlinkedTemplatesPage', 'Mostlinkedtemplates' ), array( 'MostlinkedPage', 'Mostlinked' ), array( 'MostrevisionsPage', 'Mostrevisions' ), array( 'FewestrevisionsPage', 'Fewestrevisions' ), @@ -97,15 +96,11 @@ abstract class QueryPage extends SpecialPage { array( 'WantedFilesPage', 'Wantedfiles' ), array( 'WantedPagesPage', 'Wantedpages' ), array( 'WantedTemplatesPage', 'Wantedtemplates' ), - array( 'UnwatchedPagesPage', 'Unwatchedpages' ), + array( 'UnwatchedpagesPage', 'Unwatchedpages' ), array( 'UnusedtemplatesPage', 'Unusedtemplates' ), array( 'WithoutInterwikiPage', 'Withoutinterwiki' ), ); - wfRunHooks( 'wgQueryPages', array( &$qp ) ); - - if ( !$wgDisableCounters ) { - $qp[] = array( 'PopularPagesPage', 'Popularpages' ); - } + Hooks::run( 'wgQueryPages', array( &$qp ) ); } return $qp; @@ -351,7 +346,7 @@ abstract class QueryPage extends SpecialPage { /** * Get a DB connection to be used for slow recache queries - * @return DatabaseBase + * @return IDatabase */ function getRecacheDB() { return wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) ); @@ -581,7 +576,7 @@ abstract class QueryPage extends SpecialPage { * * @param OutputPage $out OutputPage to print to * @param Skin $skin User skin to use - * @param DatabaseBase $dbr Database (read) connection to use + * @param IDatabase $dbr Database (read) connection to use * @param ResultWrapper $res Result pointer * @param int $num Number of available result rows * @param int $offset Paging offset @@ -654,7 +649,7 @@ abstract class QueryPage extends SpecialPage { /** * Do any necessary preprocessing of the result object. - * @param DatabaseBase $db + * @param IDatabase $db * @param ResultWrapper $res */ function preprocessResults( $db, $res ) { diff --git a/includes/specialpage/RedirectSpecialPage.php b/includes/specialpage/RedirectSpecialPage.php index 4226ee02..2e6e55a7 100644 --- a/includes/specialpage/RedirectSpecialPage.php +++ b/includes/specialpage/RedirectSpecialPage.php @@ -203,7 +203,7 @@ abstract class RedirectSpecialArticle extends RedirectSpecialPage { 'ctype', 'maxage', 'smaxage', ); - wfRunHooks( "RedirectSpecialArticleRedirectParams", array( &$redirectParams ) ); + Hooks::run( "RedirectSpecialArticleRedirectParams", array( &$redirectParams ) ); $this->mAllowedRedirectParams = $redirectParams; } } diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index c0a94af1..a7a43b0e 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -303,26 +303,46 @@ class SpecialPage { * - `prefixSearchSubpages( "" )` should return `array( foo", "bar", "baz" )` * * @param string $search Prefix to search for - * @param int $limit Maximum number of results to return + * @param int $limit Maximum number of results to return (usually 10) + * @param int $offset Number of results to skip (usually 0) * @return string[] Matching subpages */ - public function prefixSearchSubpages( $search, $limit = 10 ) { + public function prefixSearchSubpages( $search, $limit, $offset ) { + $subpages = $this->getSubpagesForPrefixSearch(); + if ( !$subpages ) { + return array(); + } + + return self::prefixSearchArray( $search, $limit, $subpages, $offset ); + } + + /** + * Return an array of subpages that this special page will accept for prefix + * searches. If this method requires a query you might instead want to implement + * prefixSearchSubpages() directly so you can support $limit and $offset. This + * method is better for static-ish lists of things. + * + * @return string[] subpages to search from + */ + protected function getSubpagesForPrefixSearch() { return array(); } /** * Helper function for implementations of prefixSearchSubpages() that - * filter the values in memory (as oppposed to making a query). + * filter the values in memory (as opposed to making a query). * * @since 1.24 * @param string $search * @param int $limit * @param array $subpages + * @param int $offset * @return string[] */ - protected static function prefixSearchArray( $search, $limit, array $subpages ) { + protected static function prefixSearchArray( $search, $limit, array $subpages, $offset ) { $escaped = preg_quote( $search, '/' ); - return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit ); + return array_slice( preg_grep( "/^$escaped/i", + array_slice( $subpages, $offset ) ), 0, $limit ); } /** @@ -336,6 +356,7 @@ class SpecialPage { if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) { $out->addModuleStyles( array( 'mediawiki.ui.input', + 'mediawiki.ui.radio', 'mediawiki.ui.checkbox', ) ); } @@ -357,7 +378,7 @@ class SpecialPage { * @param SpecialPage $this * @param string|null $subPage */ - wfRunHooks( 'SpecialPageBeforeExecute', array( $this, $subPage ) ); + Hooks::run( 'SpecialPageBeforeExecute', array( $this, $subPage ) ); $this->beforeExecute( $subPage ); $this->execute( $subPage ); @@ -371,7 +392,7 @@ class SpecialPage { * @param SpecialPage $this * @param string|null $subPage */ - wfRunHooks( 'SpecialPageAfterExecute', array( $this, $subPage ) ); + Hooks::run( 'SpecialPageAfterExecute', array( $this, $subPage ) ); } /** @@ -611,6 +632,26 @@ class SpecialPage { } } + /** + * Adds help link with an icon via page indicators. + * Link target can be overridden by a local message containing a wikilink: + * the message key is: lowercase special page name + '-helppage'. + * @param string $to Target MediaWiki.org page title or encoded URL. + * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o. + * @since 1.25 + */ + public function addHelpLink( $to, $overrideBaseUrl = false ) { + global $wgContLang; + $msg = $this->msg( $wgContLang->lc( $this->getName() ) . '-helppage' ); + + if ( !$msg->isDisabled() ) { + $helpUrl = Skin::makeUrl( $msg->plain() ); + $this->getOutput()->addHelpLink( $helpUrl, true ); + } else { + $this->getOutput()->addHelpLink( $to, $overrideBaseUrl ); + } + } + /** * Get the group that the special page belongs in on Special:SpecialPage * Use this method, instead of getGroupName to allow customization diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 23fdc71a..dedfcb6a 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -47,7 +47,7 @@ class SpecialPageFactory { /** * List of special page names to the subclass of SpecialPage which handles them. */ - private static $list = array( + private static $coreList = array( // Maintenance Reports 'BrokenRedirects' => 'BrokenRedirectsPage', 'Deadendpages' => 'DeadendPagesPage', @@ -59,7 +59,7 @@ class SpecialPageFactory { 'Withoutinterwiki' => 'WithoutInterwikiPage', 'Protectedpages' => 'SpecialProtectedpages', 'Protectedtitles' => 'SpecialProtectedtitles', - 'Shortpages' => 'ShortpagesPage', + 'Shortpages' => 'ShortPagesPage', 'Uncategorizedcategories' => 'UncategorizedCategoriesPage', 'Uncategorizedimages' => 'UncategorizedImagesPage', 'Uncategorizedpages' => 'UncategorizedPagesPage', @@ -156,8 +156,10 @@ class SpecialPageFactory { 'Booksources' => 'SpecialBookSources', // Unlisted / redirects + 'ApiHelp' => 'SpecialApiHelp', 'Blankpage' => 'SpecialBlankpage', 'Diff' => 'SpecialDiff', + 'EditTags' => 'SpecialEditTags', 'Emailuser' => 'SpecialEmailUser', 'Movepage' => 'MovePageForm', 'Mycontributions' => 'SpecialMycontributions', @@ -174,6 +176,7 @@ class SpecialPageFactory { 'Userlogout' => 'SpecialUserlogout', ); + private static $list; private static $aliases; /** @@ -213,16 +216,13 @@ class SpecialPageFactory { */ private static function getPageList() { global $wgSpecialPages; - global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication; + global $wgDisableInternalSearch, $wgEmailAuthentication; global $wgEnableEmail, $wgEnableJavaScriptTest; global $wgPageLanguageUseDB; - if ( !is_object( self::$list ) ) { - wfProfileIn( __METHOD__ ); + if ( !is_array( self::$list ) ) { - if ( !$wgDisableCounters ) { - self::$list['Popularpages'] = 'PopularPagesPage'; - } + self::$list = self::$coreList; if ( !$wgDisableInternalSearch ) { self::$list['Search'] = 'SpecialSearch'; @@ -250,11 +250,10 @@ class SpecialPageFactory { // Add extension special pages self::$list = array_merge( self::$list, $wgSpecialPages ); - // Run hooks - // This hook can be used to remove undesired built-in special pages - wfRunHooks( 'SpecialPage_initList', array( &self::$list ) ); + // This hook can be used to disable unwanted core special pages + // or conditionally register special pages. + Hooks::run( 'SpecialPage_initList', array( &self::$list ) ); - wfProfileOut( __METHOD__ ); } return self::$list; @@ -271,12 +270,13 @@ class SpecialPageFactory { if ( !is_object( self::$aliases ) ) { global $wgContLang; $aliases = $wgContLang->getSpecialPageAliases(); + $pageList = self::getPageList(); self::$aliases = array(); $keepAlias = array(); // Force every canonical name to be an alias for itself. - foreach ( self::getPageList() as $name => $stuff ) { + foreach ( $pageList as $name => $stuff ) { $caseFoldedAlias = $wgContLang->caseFold( $name ); self::$aliases[$caseFoldedAlias] = $name; $keepAlias[$caseFoldedAlias] = 'canonical'; @@ -413,7 +413,11 @@ class SpecialPageFactory { // @deprecated, officially since 1.18, unofficially since forever wfDeprecated( "Array syntax for \$wgSpecialPages is deprecated ($className), " . "define a subclass of SpecialPage instead.", '1.18' ); - $page = MWFunction::newObj( $className, $rec ); + $page = ObjectFactory::getObjectFromSpec( array( + 'class' => $className, + 'args' => $rec, + 'closure_expansion' => false, + ) ); } elseif ( $rec instanceof SpecialPage ) { $page = $rec; //XXX: we should deep clone here } else { @@ -522,7 +526,6 @@ class SpecialPageFactory { * @return bool */ public static function executePath( Title &$title, IContextSource &$context, $including = false ) { - wfProfileIn( __METHOD__ ); // @todo FIXME: Redirects broken due to this call $bits = explode( '/', $title->getDBkey(), 2 ); @@ -544,7 +547,6 @@ class SpecialPageFactory { } $context->getOutput()->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' ); - wfProfileOut( __METHOD__ ); return false; } @@ -564,14 +566,12 @@ class SpecialPageFactory { $title = $page->getPageTitle( $par ); $url = $title->getFullURL( $query ); $context->getOutput()->redirect( $url ); - wfProfileOut( __METHOD__ ); return $title; } else { $context->setTitle( $page->getPageTitle( $par ) ); } } elseif ( !$page->isIncludable() ) { - wfProfileOut( __METHOD__ ); return false; } @@ -579,11 +579,7 @@ class SpecialPageFactory { $page->including( $including ); // Execute special page - $profName = 'Special:' . $page->getName(); - wfProfileIn( $profName ); $page->run( $par ); - wfProfileOut( $profName ); - wfProfileOut( __METHOD__ ); return true; } diff --git a/includes/specialpage/WantedQueryPage.php b/includes/specialpage/WantedQueryPage.php index be2f1e8d..c4140de1 100644 --- a/includes/specialpage/WantedQueryPage.php +++ b/includes/specialpage/WantedQueryPage.php @@ -37,7 +37,7 @@ abstract class WantedQueryPage extends QueryPage { /** * Cache page existence for performance - * @param DatabaseBase $db + * @param IDatabase $db * @param ResultWrapper $res */ function preprocessResults( $db, $res ) { @@ -109,7 +109,7 @@ abstract class WantedQueryPage extends QueryPage { * @note This will only be run if the page is cached (ie $wgMiserMode = true) * unless forceExistenceCheck() is true. * @since 1.24 - * @return boolean + * @return bool */ protected function existenceCheck( Title $title ) { return $title->isKnown(); -- cgit v1.2.3-54-g00ecf