Stop stubbing $wgLang and $wgContLang. There are no major code paths which do not...
authorHappy-melon <happy-melon@users.mediawiki.org>
Sat, 23 Apr 2011 15:19:38 +0000 (15:19 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sat, 23 Apr 2011 15:19:38 +0000 (15:19 +0000)
includes/Message.php
includes/Setup.php
includes/StubObject.php
languages/Language.php
tests/parser/parserTest.inc
tests/phpunit/includes/ArticleTablesTest.php
tests/phpunit/includes/ParserOptionsTest.php
tests/phpunit/includes/parser/NewParserTest.php
tests/phpunit/suites/UploadFromUrlTestSuite.php

index d4ea091..8097d43 100644 (file)
@@ -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 ) {
index ec1b999..bcf7549 100644 (file)
@@ -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
index 1c5460b..1dd597c 100644 (file)
@@ -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 {
 
index 8395dc0..4462100 100644 (file)
@@ -73,7 +73,11 @@ class Language {
         */
        var $transformData = array();
 
+       /**
+        * @var LocalisationCache
+        */
        static public $dataCache;
+
        static public $mLangObjCache = array();
 
        static public $mWeekdayMsgs = array(
index b1a4e22..b3aaee7 100644 (file)
@@ -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;
index a35af50..537f004 100644 (file)
@@ -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();
        }
 
        /**
index 02d6b17..58c8914 100644 (file)
@@ -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();
        }
index 8a2c7d1..386845c 100644 (file)
@@ -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;
index db8efce..bd18af3 100644 (file)
@@ -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;