From 73776c92ee06f46e90d2bfb2cf2f5abbc4995b77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Mon, 6 Jun 2011 17:55:19 +0000 Subject: [PATCH] Fix for bug 29274 - Message class ignores $wgForceUIMsgAsContentMsg Also added tests, which pass --- includes/Message.php | 6 ++++++ tests/phpunit/includes/MessageTest.php | 8 ++++++++ 2 files changed, 14 insertions(+) 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' ); } /** -- 2.20.1