From: Happy-melon Date: Sat, 23 Apr 2011 15:19:38 +0000 (+0000) Subject: Stop stubbing $wgLang and $wgContLang. There are no major code paths which do not... X-Git-Tag: 1.31.0-rc.0~30605 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=c80535ae10c7c15b4cbdecd5bad78431fd197ed9;p=lhc%2Fweb%2Fwiklou.git Stop stubbing $wgLang and $wgContLang. There are no major code paths which do not call either $wgLang or $wgContLang at least once. All index.php calls unstub $wgContLang from MediaWiki::parseTitle() except in the edgecase of viewing pages referenced only by "curid=123", and since those will end up calling OutputPage::output() they will eventually be unstubbed at some point as well. All calls through load.php unstub $wgLang in ResourceLoaderContext::getLanguage() from ResouceLoader::respond() --> ResourceLoader::preloadModuleInfo(). All calls through api.php unstub $wgContLang in ApiResult::cleanUpUTF8() from ApiMain::printResult(). --- diff --git a/includes/Message.php b/includes/Message.php index d4ea091c56..8097d4382a 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -208,7 +208,7 @@ class Message { * @return Message: $this */ public function inLanguage( $lang ) { - if ( $lang instanceof Language || $lang instanceof StubContLang || $lang instanceof StubUserLang ) { + if ( $lang instanceof Language ) { $this->language = $lang; } elseif ( is_string( $lang ) ) { if( $this->language->getCode() != $lang ) { diff --git a/includes/Setup.php b/includes/Setup.php index ec1b999ba9..bcf754954b 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -397,7 +397,9 @@ if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) { wfProfileOut( $fname . '-session' ); wfProfileIn( $fname . '-globals' ); -$wgContLang = new StubContLang; +$wgContLang = Language::factory( $wgLanguageCode ); +$wgContLang->initEncoding(); +$wgContLang->initContLang(); // Now that variant lists may be available... $wgRequest->interpolateTitle(); @@ -406,7 +408,7 @@ $wgUser = RequestContext::getMain()->getUser(); # BackCompat /** * @var Language */ -$wgLang = new StubUserLang; +$wgLang = RequestContext::getMain()->getLang(); /** * @var OutputPage diff --git a/includes/StubObject.php b/includes/StubObject.php index 1c5460b986..1dd597c3f3 100644 --- a/includes/StubObject.php +++ b/includes/StubObject.php @@ -110,6 +110,8 @@ class StubObject { /** * Stub object for the content language of this wiki. This object have to be in * $wgContLang global. + * + * @deprecated since 1.18 */ class StubContLang extends StubObject { @@ -134,6 +136,8 @@ class StubContLang extends StubObject { * Stub object for the user language. It depends of the user preferences and * "uselang" parameter that can be passed to index.php. This object have to be * in $wgLang global. + * + * @deprecated since 1.18 */ class StubUserLang extends StubObject { diff --git a/languages/Language.php b/languages/Language.php index 8395dc0e46..4462100225 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -73,7 +73,11 @@ class Language { */ var $transformData = array(); + /** + * @var LocalisationCache + */ static public $dataCache; + static public $mLangObjCache = array(); static public $mWeekdayMsgs = array( diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index b1a4e224e1..b3aaee785e 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -166,7 +166,7 @@ class ParserTest { // $wgContLang = new StubContLang; $wgUser = new User; - $wgLang = new StubUserLang; + $wgLang = Language::factory( 'en' ); $wgOut = new StubObject( 'wgOut', 'OutputPage' ); $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) ); $wgRequest = new WebRequest; diff --git a/tests/phpunit/includes/ArticleTablesTest.php b/tests/phpunit/includes/ArticleTablesTest.php index a35af50e41..537f004dd9 100644 --- a/tests/phpunit/includes/ArticleTablesTest.php +++ b/tests/phpunit/includes/ArticleTablesTest.php @@ -15,8 +15,8 @@ class ArticleTablesTest extends MediaWikiTestCase { function tearDown() { global $wgLanguageCode, $wgContLang, $wgLang; $wgLanguageCode = $this->languageCode; - $wgContLang = new StubContLang; - $wgLang = new StubUserLang; + $wgContLang = Language::factory( $wgLanguageCode ); + $wgLang = RequestContext::getMain()->getLang(); } /** diff --git a/tests/phpunit/includes/ParserOptionsTest.php b/tests/phpunit/includes/ParserOptionsTest.php index 02d6b17dfb..58c891462f 100644 --- a/tests/phpunit/includes/ParserOptionsTest.php +++ b/tests/phpunit/includes/ParserOptionsTest.php @@ -7,8 +7,8 @@ class ParserOptionsTest extends MediaWikiTestCase { function setUp() { ParserTest::setUp(); //reuse setup from parser tests - global $wgContLang, $wgUser; - $wgContLang = new StubContLang; + global $wgContLang, $wgUser, $wgLanguageCode; + $wgContLang = Language::factory( $wgLanguageCode ); $this->popts = new ParserOptions( $wgUser ); $this->pcache = ParserCache::singleton(); } diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 8a2c7d1c17..386845ce32 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -76,7 +76,7 @@ class NewParserTest extends MediaWikiTestCase { // $tmpGlobals['wgContLang'] = new StubContLang; $tmpGlobals['wgUser'] = new User; - $tmpGlobals['wgLang'] = new StubUserLang; + $tmpGlobals['wgLang'] = Language::factory( 'en' ); $tmpGlobals['wgOut'] = new StubObject( 'wgOut', 'OutputPage' ); $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) ); $tmpGlobals['wgRequest'] = new WebRequest; diff --git a/tests/phpunit/suites/UploadFromUrlTestSuite.php b/tests/phpunit/suites/UploadFromUrlTestSuite.php index db8efcef10..bd18af3f42 100644 --- a/tests/phpunit/suites/UploadFromUrlTestSuite.php +++ b/tests/phpunit/suites/UploadFromUrlTestSuite.php @@ -48,7 +48,7 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite { // $wgContLang = new StubContLang; $wgUser = new User; - $wgLang = new StubUserLang; + $wgLang = Language::factory( 'en' ); $wgOut = new StubObject( 'wgOut', 'OutputPage' ); $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) ); $wgRequest = new WebRequest;