r89585 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89584‎ | r89585 | r89586 >
Date:17:55, 6 June 2011
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
Fix for bug 29274 - Message class ignores $wgForceUIMsgAsContentMsg
Also added tests, which pass
Modified paths:
  • /trunk/phase3/includes/Message.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/MessageTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/MessageTest.php
@@ -37,7 +37,15 @@
3838 $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses', 'Заглавная страница $1' )->plain() );
3939 $this->assertEquals( '(Заглавная страница)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница' )->plain() );
4040 $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница $1' )->plain() );
 41+ }
4142
 43+ function testInContentLanguage() {
 44+ global $wgLang, $wgForceUIMsgAsContentMsg;
 45+ $wgLang = Language::factory( 'fr' );
 46+
 47+ $this->assertEquals( 'Main Page', wfMessage( 'mainpage' )->inContentLanguage()->plain(), "ForceUIMsg disabled" );
 48+ $wgForceUIMsgAsContentMsg[] = 'mainpage';
 49+ $this->assertEquals( 'Accueil', wfMessage( 'mainpage' )->inContentLanguage()->plain(), 'ForceUIMsg enabled' );
4250 }
4351
4452 /**
Index: trunk/phase3/includes/Message.php
@@ -225,9 +225,15 @@
226226
227227 /**
228228 * Request the message in the wiki's content language.
 229+ * @see $wgForceUIMsgAsContentMsg
229230 * @return Message: $this
230231 */
231232 public function inContentLanguage() {
 233+ global $wgForceUIMsgAsContentMsg;
 234+ if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
 235+ return $this;
 236+ }
 237+
232238 global $wgContLang;
233239 $this->interface = false;
234240 $this->language = $wgContLang;

Follow-up revisions

RevisionCommit summaryAuthorDate
r89612Follow up r89585. Clean up after the test, expand inContentLanguage() comment.platonides21:24, 6 June 2011

Comments

#Comment by Platonides (talk | contribs)   21:24, 6 June 2011

Confirmed fixed. I improved it a bit in r89612.

Status & tagging log