r86809 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86808‎ | r86809 | r86810 >
Date:10:50, 24 April 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/Message.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/StubObject.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/ArticleTablesTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/suites/UploadFromUrlTestSuite.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/ArticleTablesTest.php
@@ -16,7 +16,7 @@
1717 global $wgLanguageCode, $wgContLang, $wgLang;
1818 $wgLanguageCode = $this->languageCode;
1919 $wgContLang = Language::factory( $wgLanguageCode );
20 - $wgLang = RequestContext::getMain()->getLang();
 20+ $wgLang = new StubUserLang;
2121 }
2222
2323 /**
Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php
@@ -76,7 +76,7 @@
7777
7878 // $tmpGlobals['wgContLang'] = new StubContLang;
7979 $tmpGlobals['wgUser'] = new User;
80 - $tmpGlobals['wgLang'] = Language::factory( 'en' );
 80+ $tmpGlobals['wgLang'] = new StubUserLang;
8181 $tmpGlobals['wgOut'] = new StubObject( 'wgOut', 'OutputPage' );
8282 $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) );
8383 $tmpGlobals['wgRequest'] = new WebRequest;
Index: trunk/phase3/tests/phpunit/suites/UploadFromUrlTestSuite.php
@@ -48,7 +48,7 @@
4949
5050 // $wgContLang = new StubContLang;
5151 $wgUser = new User;
52 - $wgLang = Language::factory( 'en' );
 52+ $wgLang = new StubUserLang;
5353 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
5454 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
5555 $wgRequest = new WebRequest;
Index: trunk/phase3/tests/parser/parserTest.inc
@@ -166,7 +166,7 @@
167167
168168 // $wgContLang = new StubContLang;
169169 $wgUser = new User;
170 - $wgLang = Language::factory( 'en' );
 170+ $wgLang = new StubUserLang;
171171 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
172172 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
173173 $wgRequest = new WebRequest;
Index: trunk/phase3/includes/StubObject.php
@@ -136,8 +136,6 @@
137137 * Stub object for the user language. It depends of the user preferences and
138138 * "uselang" parameter that can be passed to index.php. This object have to be
139139 * in $wgLang global.
140 - *
141 - * @deprecated since 1.18
142140 */
143141 class StubUserLang extends StubObject {
144142
Index: trunk/phase3/includes/Message.php
@@ -208,7 +208,7 @@
209209 * @return Message: $this
210210 */
211211 public function inLanguage( $lang ) {
212 - if ( $lang instanceof Language ) {
 212+ if ( $lang instanceof Language || $lang instanceof StubUserLang ) {
213213 $this->language = $lang;
214214 } elseif ( is_string( $lang ) ) {
215215 if( $this->language->getCode() != $lang ) {
Index: trunk/phase3/includes/Setup.php
@@ -408,7 +408,7 @@
409409 /**
410410 * @var Language
411411 */
412 -$wgLang = RequestContext::getMain()->getLang();
 412+$wgLang = new StubUserLang;
413413
414414 /**
415415 * @var OutputPage

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86775Stop stubbing $wgLang and $wgContLang. There are no major code paths which d...happy-melon15:19, 23 April 2011

Comments

#Comment by MarkAHershberger (talk | contribs)   02:22, 25 April 2011

thank you!

Status & tagging log