Merge "MessagesEs.php: add non-camelcase names to some special page names"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 21 Apr 2018 12:52:15 +0000 (12:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 21 Apr 2018 12:52:16 +0000 (12:52 +0000)
includes/GlobalFunctions.php
includes/resourceloader/ResourceLoaderWikiModule.php
includes/specials/SpecialAutoblockList.php
includes/specials/SpecialBlockList.php
includes/specials/SpecialFileDuplicateSearch.php
includes/specials/SpecialNewpages.php
tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php

index 1a3f50a..519b22c 100644 (file)
@@ -2559,6 +2559,7 @@ function wfDiff( $before, $after, $params = '-u' ) {
  * @throws MWException
  */
 function wfUsePHP( $req_ver ) {
+       wfDeprecated( __FUNCTION__, '1.30' );
        $php_ver = PHP_VERSION;
 
        if ( version_compare( $php_ver, (string)$req_ver, '<' ) ) {
@@ -3035,6 +3036,7 @@ function wfWaitForSlaves(
  * @param int $seconds
  */
 function wfCountDown( $seconds ) {
+       wfDeprecated( __FUNCTION__, '1.31' );
        for ( $i = $seconds; $i >= 0; $i-- ) {
                if ( $i != $seconds ) {
                        echo str_repeat( "\x08", strlen( $i + 1 ) );
index 5b512af..0926b60 100644 (file)
@@ -22,6 +22,7 @@
  * @author Roan Kattouw
  */
 
+use MediaWiki\Linker\LinkTarget;
 use Wikimedia\Rdbms\Database;
 use Wikimedia\Rdbms\IDatabase;
 
@@ -50,7 +51,19 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
        // Origin defaults to users with sitewide authority
        protected $origin = self::ORIGIN_USER_SITEWIDE;
 
-       // In-process cache for title info
+       // In-process cache for title info, structured as an array
+       // [
+       //  <batchKey> // Pipe-separated list of sorted keys from getPages
+       //   => [
+       //     <titleKey> => [ // Normalised title key
+       //       'page_len' => ..,
+       //       'page_latest' => ..,
+       //       'page_touched' => ..,
+       //     ]
+       //   ]
+       // ]
+       // @see self::fetchTitleInfo()
+       // @see self::makeTitleKey()
        protected $titleInfo = [];
 
        // List of page names that contain CSS
@@ -295,8 +308,13 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                return count( $revisions ) === 0;
        }
 
-       private function setTitleInfo( $key, array $titleInfo ) {
-               $this->titleInfo[$key] = $titleInfo;
+       private function setTitleInfo( $batchKey, array $titleInfo ) {
+               $this->titleInfo[$batchKey] = $titleInfo;
+       }
+
+       private static function makeTitleKey( LinkTarget $title ) {
+               // Used for keys in titleInfo.
+               return "{$title->getNamespace()}:{$title->getDBkey()}";
        }
 
        /**
@@ -313,11 +331,11 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
 
                $pageNames = array_keys( $this->getPages( $context ) );
                sort( $pageNames );
-               $key = implode( '|', $pageNames );
-               if ( !isset( $this->titleInfo[$key] ) ) {
-                       $this->titleInfo[$key] = static::fetchTitleInfo( $dbr, $pageNames, __METHOD__ );
+               $batchKey = implode( '|', $pageNames );
+               if ( !isset( $this->titleInfo[$batchKey] ) ) {
+                       $this->titleInfo[$batchKey] = static::fetchTitleInfo( $dbr, $pageNames, __METHOD__ );
                }
-               return $this->titleInfo[$key];
+               return $this->titleInfo[$batchKey];
        }
 
        protected static function fetchTitleInfo( IDatabase $db, array $pages, $fname = __METHOD__ ) {
@@ -340,8 +358,8 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        foreach ( $res as $row ) {
                                // Avoid including ids or timestamps of revision/page tables so
                                // that versions are not wasted
-                               $title = Title::makeTitle( $row->page_namespace, $row->page_title );
-                               $titleInfo[$title->getPrefixedText()] = [
+                               $title = new TitleValue( (int)$row->page_namespace, $row->page_title );
+                               $titleInfo[ self::makeTitleKey( $title ) ] = [
                                        'page_len' => $row->page_len,
                                        'page_latest' => $row->page_latest,
                                        'page_touched' => $row->page_touched,
@@ -410,23 +428,23 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        $pages = $wikiModule->getPages( $context );
                        // Before we intersect, map the names to canonical form (T145673).
                        $intersect = [];
-                       foreach ( $pages as $page => $unused ) {
-                               $title = Title::newFromText( $page );
+                       foreach ( $pages as $pageName => $unused ) {
+                               $title = Title::newFromText( $pageName );
                                if ( $title ) {
-                                       $intersect[ $title->getPrefixedText() ] = 1;
+                                       $intersect[ self::makeTitleKey( $title ) ] = 1;
                                } else {
                                        // Page name may be invalid if user-provided (e.g. gadgets)
                                        $rl->getLogger()->info(
                                                'Invalid wiki page title "{title}" in ' . __METHOD__,
-                                               [ 'title' => $page ]
+                                               [ 'title' => $pageName ]
                                        );
                                }
                        }
                        $info = array_intersect_key( $allInfo, $intersect );
                        $pageNames = array_keys( $pages );
                        sort( $pageNames );
-                       $key = implode( '|', $pageNames );
-                       $wikiModule->setTitleInfo( $key, $info );
+                       $batchKey = implode( '|', $pageNames );
+                       $wikiModule->setTitleInfo( $batchKey, $info );
                }
        }
 
index bf13865..4d2d1b9 100644 (file)
@@ -74,7 +74,6 @@ class SpecialAutoblockList extends SpecialPage {
                        ->setFormIdentifier( 'blocklist' )
                        ->setWrapperLegendMsg( 'autoblocklist-legend' )
                        ->setSubmitTextMsg( 'autoblocklist-submit' )
-                       ->setSubmitProgressive()
                        ->prepareForm()
                        ->displayForm( false );
 
index 0899d58..667b814 100644 (file)
@@ -108,7 +108,6 @@ class SpecialBlockList extends SpecialPage {
                        ->setFormIdentifier( 'blocklist' )
                        ->setWrapperLegendMsg( 'ipblocklist-legend' )
                        ->setSubmitTextMsg( 'ipblocklist-submit' )
-                       ->setSubmitProgressive()
                        ->prepareForm()
                        ->displayForm( false );
 
index 7694a61..e6d81c9 100644 (file)
@@ -131,7 +131,6 @@ class FileDuplicateSearchPage extends QueryPage {
                $htmlForm->addHiddenFields( $hiddenFields );
                $htmlForm->setAction( wfScript() );
                $htmlForm->setMethod( 'get' );
-               $htmlForm->setSubmitProgressive();
                $htmlForm->setSubmitTextMsg( $this->msg( 'fileduplicatesearch-submit' ) );
 
                // The form should be visible always, even if it was submitted (e.g. to perform another action).
index 46d5276..efe6758 100644 (file)
@@ -269,7 +269,6 @@ class SpecialNewpages extends IncludableSpecialPage {
                $htmlForm = new HTMLForm( $form, $this->getContext() );
 
                $htmlForm->setSubmitText( $this->msg( 'newpages-submit' )->text() );
-               $htmlForm->setSubmitProgressive();
                // The form should be visible on each request (inclusive requests with submitted forms), so
                // return always false here.
                $htmlForm->setSubmitCallback(
index 0aa37d2..d4b9c16 100644 (file)
@@ -15,6 +15,15 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
                $this->assertInstanceOf( ResourceLoaderWikiModule::class, $module );
        }
 
+       private function prepareTitleInfo( array $mockInfo ) {
+               $module = TestingAccessWrapper::newFromClass( ResourceLoaderWikiModule::class );
+               $info = [];
+               foreach ( $mockInfo as $key => $val ) {
+                       $info[ $module->makeTitleKey( Title::newFromText( $key ) ) ] = $val;
+               }
+               return $info;
+       }
+
        public static function provideConstructor() {
                return [
                        // Nothing
@@ -102,7 +111,7 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
                        ->getMock();
                $module->expects( $this->any() )
                        ->method( 'getTitleInfo' )
-                       ->will( $this->returnValue( $titleInfo ) );
+                       ->will( $this->returnValue( $this->prepareTitleInfo( $titleInfo ) ) );
                $module->expects( $this->any() )
                        ->method( 'getGroup' )
                        ->will( $this->returnValue( $group ) );
@@ -151,10 +160,10 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
                        'MediaWiki:Common.css' => [ 'type' => 'styles' ],
                        'mediawiki: fallback.css' => [ 'type' => 'styles' ],
                ];
-               $titleInfo = [
+               $titleInfo = $this->prepareTitleInfo( [
                        'MediaWiki:Common.css' => [ 'page_len' => 1234 ],
                        'MediaWiki:Fallback.css' => [ 'page_len' => 0 ],
-               ];
+               ] );
                $expected = $titleInfo;
 
                $module = $this->getMockBuilder( TestResourceLoaderWikiModule::class )
@@ -186,10 +195,10 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
                        // doing an intersect on the canonical result, producing an empty array.
                        'mediawiki: fallback.css' => [ 'type' => 'styles' ],
                ];
-               $titleInfo = [
+               $titleInfo = $this->prepareTitleInfo( [
                        'MediaWiki:Common.css' => [ 'page_len' => 1234 ],
                        'MediaWiki:Fallback.css' => [ 'page_len' => 0 ],
-               ];
+               ] );
                $expected = $titleInfo;
 
                $module = $this->getMockBuilder( TestResourceLoaderWikiModule::class )