Merge "resourceloader: Disable localStorage cache on FF, Opera"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 10 Feb 2016 15:59:18 +0000 (15:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 10 Feb 2016 15:59:18 +0000 (15:59 +0000)
includes/installer/CliInstaller.php
includes/installer/Installer.php
includes/libs/ReplacementArray.php
mw-config/index.php
tests/phpunit/includes/libs/ArrayUtilsTest.php
tests/phpunit/includes/site/CachingSiteStoreTest.php
tests/phpunit/includes/site/SiteImporterTest.php

index 7290740..55ec8df 100644 (file)
@@ -75,6 +75,7 @@ class CliInstaller extends Installer {
                        $wgContLang = Language::factory( $option['lang'] );
                        $wgLang = Language::factory( $option['lang'] );
                        $wgLanguageCode = $option['lang'];
+                       RequestContext::getMain()->setLanguage( $wgLang );
                }
 
                $this->setVar( 'wgSitename', $siteName );
index e61e2d2..40e51f0 100644 (file)
@@ -361,6 +361,10 @@ abstract class Installer {
        public function __construct() {
                global $wgMessagesDirs, $wgUser;
 
+               // Don't attempt to load user language options (T126177)
+               // This will be overridden in the web installer with the user-specified language
+               RequestContext::getMain()->setLanguage( 'en' );
+
                // Disable the i18n cache
                Language::getLocalisationCache()->disableBackend();
                // Disable LoadBalancer and wfGetDB etc.
@@ -385,6 +389,7 @@ abstract class Installer {
 
                // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
                $wgUser = User::newFromId( 0 );
+               RequestContext::getMain()->setUser( $wgUser );
 
                $this->settings = $this->internalDefaults;
 
@@ -405,7 +410,7 @@ abstract class Installer {
                }
 
                $this->parserTitle = Title::newFromText( 'Installer' );
-               $this->parserOptions = new ParserOptions; // language will be wrong :(
+               $this->parserOptions = new ParserOptions( $wgUser ); // language will be wrong :(
                $this->parserOptions->setEditSection( false );
        }
 
index ea50a85..02762f3 100644 (file)
  */
 
 /**
- * Replacement array for FSS with fallback to strtr()
- * Supports lazy initialisation of FSS resource
+ * Wrapper around strtr() that holds replacements
  */
 class ReplacementArray {
        private $data = false;
-       private $fss = false;
 
        /**
         * Create an object with the specified replacement array
         * The array should have the same form as the replacement array for strtr()
         * @param array $data
         */
-       public function __construct( $data = array() ) {
+       public function __construct( $data = [] ) {
                $this->data = $data;
        }
 
@@ -42,17 +40,12 @@ class ReplacementArray {
                return array( 'data' );
        }
 
-       public function __wakeup() {
-               $this->fss = false;
-       }
-
        /**
         * Set the whole replacement array at once
         * @param array $data
         */
        public function setArray( $data ) {
                $this->data = $data;
-               $this->fss = false;
        }
 
        /**
@@ -69,7 +62,6 @@ class ReplacementArray {
         */
        public function setPair( $from, $to ) {
                $this->data[$from] = $to;
-               $this->fss = false;
        }
 
        /**
@@ -77,7 +69,6 @@ class ReplacementArray {
         */
        public function mergeArray( $data ) {
                $this->data = $data + $this->data;
-               $this->fss = false;
        }
 
        /**
@@ -85,7 +76,6 @@ class ReplacementArray {
         */
        public function merge( ReplacementArray $other ) {
                $this->data = $other->data + $this->data;
-               $this->fss = false;
        }
 
        /**
@@ -93,7 +83,6 @@ class ReplacementArray {
         */
        public function removePair( $from ) {
                unset( $this->data[$from] );
-               $this->fss = false;
        }
 
        /**
@@ -103,7 +92,6 @@ class ReplacementArray {
                foreach ( $data as $from => $to ) {
                        $this->removePair( $from );
                }
-               $this->fss = false;
        }
 
        /**
@@ -111,18 +99,6 @@ class ReplacementArray {
         * @return string
         */
        public function replace( $subject ) {
-               if (
-                       function_exists( 'fss_prep_replace' ) &&
-                       version_compare( PHP_VERSION, '5.5.0' ) < 0
-               ) {
-                       if ( $this->fss === false ) {
-                               $this->fss = fss_prep_replace( $this->data );
-                       }
-                       $result = fss_exec_replace( $this->fss, $subject );
-               } else {
-                       $result = strtr( $subject, $this->data );
-               }
-
-               return $result;
+               return strtr( $subject, $this->data );
        }
 }
index 31b201c..75a93a3 100644 (file)
@@ -71,6 +71,7 @@ function wfInstallerMain() {
                $langCode = 'en';
        }
        $wgLang = Language::factory( $langCode );
+       RequestContext::getMain()->setLanguage( $wgLang );
 
        $installer->setParserLanguage( $wgLang );
 
index 32b150c..3efc4c3 100644 (file)
@@ -23,11 +23,10 @@ class ArrayUtilsTest extends PHPUnit_Framework_TestCase {
        }
 
        function provideFindLowerBound() {
-               $that = $this;
-               $indexValueCallback = function ( $size ) use ( $that ) {
-                       return function ( $val ) use ( $that, $size ) {
-                               $that->assertTrue( $val >= 0 );
-                               $that->assertTrue( $val < $size );
+               $indexValueCallback = function ( $size ) {
+                       return function ( $val ) use ( $size ) {
+                               $this->assertTrue( $val >= 0 );
+                               $this->assertTrue( $val < $size );
                                return $val;
                        };
                };
index 4305ceb..dd62074 100644 (file)
@@ -95,18 +95,15 @@ class CachingSiteStoreTest extends MediaWikiTestCase {
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               // php 5.3 compatibility!
-               $that = $this;
-
                $dbSiteStore->expects( $this->any() )
                        ->method( 'getSite' )
-                       ->will( $this->returnValue( $that->getTestSite() ) );
+                       ->will( $this->returnValue( $this->getTestSite() ) );
 
                $dbSiteStore->expects( $this->any() )
                        ->method( 'getSites' )
-                       ->will( $this->returnCallback( function() use ( $that ) {
+                       ->will( $this->returnCallback( function() {
                                $siteList = new SiteList();
-                               $siteList->setSite( $that->getTestSite() );
+                               $siteList->setSite( $this->getTestSite() );
 
                                return $siteList;
                        } ) );
index b11b1a9..a49f06c 100644 (file)
@@ -34,11 +34,10 @@ class SiteImporterTest extends PHPUnit_Framework_TestCase {
        private function newSiteImporter( array $expectedSites, $errorCount ) {
                $store = $this->getMock( 'SiteStore' );
 
-               $that = $this;
                $store->expects( $this->once() )
                        ->method( 'saveSites' )
-                       ->will( $this->returnCallback( function ( $sites ) use ( $expectedSites, $that ) {
-                               $that->assertSitesEqual( $expectedSites, $sites );
+                       ->will( $this->returnCallback( function ( $sites ) use ( $expectedSites ) {
+                               $this->assertSitesEqual( $expectedSites, $sites );
                        } ) );
 
                $store->expects( $this->any() )