From: Niklas Laxström Date: Mon, 6 Jun 2011 17:55:19 +0000 (+0000) Subject: Fix for bug 29274 - Message class ignores $wgForceUIMsgAsContentMsg X-Git-Tag: 1.31.0-rc.0~29662 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=73776c92ee06f46e90d2bfb2cf2f5abbc4995b77;p=lhc%2Fweb%2Fwiklou.git Fix for bug 29274 - Message class ignores $wgForceUIMsgAsContentMsg Also added tests, which pass --- diff --git a/includes/Message.php b/includes/Message.php index 5f6e9af429..531712fd37 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -225,9 +225,15 @@ class Message { /** * Request the message in the wiki's content language. + * @see $wgForceUIMsgAsContentMsg * @return Message: $this */ public function inContentLanguage() { + global $wgForceUIMsgAsContentMsg; + if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) { + return $this; + } + global $wgContLang; $this->interface = false; $this->language = $wgContLang; diff --git a/tests/phpunit/includes/MessageTest.php b/tests/phpunit/includes/MessageTest.php index 02e03edad1..e1d15dc680 100644 --- a/tests/phpunit/includes/MessageTest.php +++ b/tests/phpunit/includes/MessageTest.php @@ -37,7 +37,15 @@ class MessageTest extends MediaWikiLangTestCase { $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses', 'Заглавная страница $1' )->plain() ); $this->assertEquals( '(Заглавная страница)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница' )->plain() ); $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница $1' )->plain() ); + } + + function testInContentLanguage() { + global $wgLang, $wgForceUIMsgAsContentMsg; + $wgLang = Language::factory( 'fr' ); + $this->assertEquals( 'Main Page', wfMessage( 'mainpage' )->inContentLanguage()->plain(), "ForceUIMsg disabled" ); + $wgForceUIMsgAsContentMsg[] = 'mainpage'; + $this->assertEquals( 'Accueil', wfMessage( 'mainpage' )->inContentLanguage()->plain(), 'ForceUIMsg enabled' ); } /**