In Installer, set the context language early to avoid loading from User
authorTim Starling <tstarling@wikimedia.org>
Wed, 10 Feb 2016 10:32:38 +0000 (21:32 +1100)
committerTim Starling <tstarling@wikimedia.org>
Wed, 10 Feb 2016 10:44:09 +0000 (21:44 +1100)
Set the context language early, even before the session is loaded, to
avoid attempting to call User::loadFromSession(). Also update the things
that set $wgLang to also set it in RequestContext.

Passing $wgUser through to the ParserOptions constructor isn't strictly
necessary right now, but it does at least show the intended data flow
and is more robust to future changes in the way the language is passed
through to ParserOptions.

Fixes bug T126177 independently of my other two patches.

Bug: T126177
Change-Id: I15eb9cdce7805382d96b6fc6ffb9b25855876417

includes/installer/CliInstaller.php
includes/installer/Installer.php
mw-config/index.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..f7458c4 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.
@@ -405,7 +409,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 31b201c..75a93a3 100644 (file)
@@ -71,6 +71,7 @@ function wfInstallerMain() {
                $langCode = 'en';
        }
        $wgLang = Language::factory( $langCode );
+       RequestContext::getMain()->setLanguage( $wgLang );
 
        $installer->setParserLanguage( $wgLang );