From 21813a563cb9b8850d8e080a9a796e5bb1773de8 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Sun, 24 Apr 2011 10:50:51 +0000 Subject: [PATCH] Follow-up r86775: restub $wgLang. Not because it's a good idea, but because I can't see how to avoid the circular dependencies on it *without* stubbing it. Probably easier to just continue the drive to deprecate the global variable altogether. --- includes/Message.php | 2 +- includes/Setup.php | 2 +- includes/StubObject.php | 2 -- tests/parser/parserTest.inc | 2 +- tests/phpunit/includes/ArticleTablesTest.php | 2 +- tests/phpunit/includes/parser/NewParserTest.php | 2 +- tests/phpunit/suites/UploadFromUrlTestSuite.php | 2 +- 7 files changed, 6 insertions(+), 8 deletions(-) diff --git a/includes/Message.php b/includes/Message.php index 16af7262fc..3ddbdcb684 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 ) { + if ( $lang instanceof Language || $lang instanceof StubUserLang ) { $this->language = $lang; } elseif ( is_string( $lang ) ) { if( $this->language->getCode() != $lang ) { diff --git a/includes/Setup.php b/includes/Setup.php index bcf754954b..8e9532466b 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -408,7 +408,7 @@ $wgUser = RequestContext::getMain()->getUser(); # BackCompat /** * @var Language */ -$wgLang = RequestContext::getMain()->getLang(); +$wgLang = new StubUserLang; /** * @var OutputPage diff --git a/includes/StubObject.php b/includes/StubObject.php index 1dd597c3f3..78f9f6410d 100644 --- a/includes/StubObject.php +++ b/includes/StubObject.php @@ -136,8 +136,6 @@ 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/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index b3aaee785e..b1a4e224e1 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -166,7 +166,7 @@ class ParserTest { // $wgContLang = new StubContLang; $wgUser = new User; - $wgLang = Language::factory( 'en' ); + $wgLang = new StubUserLang; $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 537f004dd9..6d7d05a224 100644 --- a/tests/phpunit/includes/ArticleTablesTest.php +++ b/tests/phpunit/includes/ArticleTablesTest.php @@ -16,7 +16,7 @@ class ArticleTablesTest extends MediaWikiTestCase { global $wgLanguageCode, $wgContLang, $wgLang; $wgLanguageCode = $this->languageCode; $wgContLang = Language::factory( $wgLanguageCode ); - $wgLang = RequestContext::getMain()->getLang(); + $wgLang = new StubUserLang; } /** diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 386845ce32..8a2c7d1c17 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'] = Language::factory( 'en' ); + $tmpGlobals['wgLang'] = new StubUserLang; $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 bd18af3f42..db8efcef10 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 = Language::factory( 'en' ); + $wgLang = new StubUserLang; $wgOut = new StubObject( 'wgOut', 'OutputPage' ); $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) ); $wgRequest = new WebRequest; -- 2.20.1