From: Brad Jorsch Date: Tue, 29 Mar 2016 18:15:12 +0000 (-0400) Subject: resourceloader: Avoid Title::newMainPage() to support $wgForceUIMsgAsContentMsg X-Git-Tag: 1.31.0-rc.0~7434^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/supprimer.php?a=commitdiff_plain;h=67984c30d63b1b0dc7d7b84e84f1810b584685c7;p=lhc%2Fweb%2Fwiklou.git resourceloader: Avoid Title::newMainPage() to support $wgForceUIMsgAsContentMsg $wgForceUIMsgAsContentMsg forces Message::inContentLanguage() to not actually do anything, thus falling back to the session user's language which we can't use in ResourceLoader. And 'mainpage' is added to that array on various multi-lingual wikis. Bug: T127233 Change-Id: I9dc1e57922641881b36c70658083c2c8c8a608a0 --- diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index d7651378a3..34866f3635 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -40,8 +40,17 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { } global $wgContLang; + $conf = $this->getConfig(); - $mainPage = Title::newMainPage(); + // We can't use Title::newMainPage() if 'mainpage' is in + // $wgForceUIMsgAsContentMsg because that will try to use the session + // user's language and we have no session user. This does the + // equivalent but falling back to our ResourceLoaderContext language + // instead. + $mainPage = Title::newFromText( $context->msg( 'mainpage' )->inContentLanguage()->text() ); + if ( !$mainPage ) { + $mainPage = Title::newFromText( 'Main Page' ); + } /** * Namespace related preparation @@ -57,7 +66,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { } } - $conf = $this->getConfig(); // Build list of variables $vars = [ 'wgLoadScript' => wfScript( 'load' ),