From b20844540e6f102329782c449f678c5b1aa9ce5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Mon, 22 Oct 2007 19:33:46 +0000 Subject: [PATCH] * (bug 11452) wfMsgExt uses sometimes wrong language object for parsing magic words when called with options ''parsemag'' or ''content''. --- RELEASE-NOTES | 3 ++- includes/GlobalFunctions.php | 6 +++--- includes/MessageCache.php | 7 +++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 89b4acca5e..89aa47e179 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -110,7 +110,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN only * Initial-lowercase prefix checks in namespaceDupes.php now actually work. * Fix regression in LinkBatch.php breaking PHP 5.0 - +* (bug 11452) wfMsgExt uses sometimes wrong language object for parsing magic + words when called with options ''parsemag'' or ''content''. === API changes in 1.12 === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 52b07d494f..312d1903dd 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -574,9 +574,9 @@ function wfMsgExt( $key, $options ) { } if( in_array('parse', $options) ) { - $string = $wgOut->parse( $string, true, true ); + $string = $wgOut->parse( $string, true, !$forContent ); } elseif ( in_array('parseinline', $options) ) { - $string = $wgOut->parse( $string, true, true ); + $string = $wgOut->parse( $string, true, !$forContent ); $m = array(); if( preg_match( '/^

(.*)\n?<\/p>\n?$/sU', $string, $m ) ) { $string = $m[1]; @@ -584,7 +584,7 @@ function wfMsgExt( $key, $options ) { } elseif ( in_array('parsemag', $options) ) { global $wgMessageCache; if ( isset( $wgMessageCache ) ) { - $string = $wgMessageCache->transform( $string ); + $string = $wgMessageCache->transform( $string, !$forContent ); } } diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 17ed899577..d1338855ef 100644 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -576,7 +576,7 @@ class MessageCache { return $message; } - function transform( $message ) { + function transform( $message, $interface = false ) { global $wgParser; if ( !$this->mParser && isset( $wgParser ) ) { # Do some initialisation so that we don't have to do it twice @@ -586,7 +586,10 @@ class MessageCache { } if ( !$this->mDisableTransform && $this->mParser ) { if( strpos( $message, '{{' ) !== false ) { - $message = $this->mParser->transformMsg( $message, $this->getParserOptions() ); + $popts = $this->getParserOptions(); + if ( $interface ) { $popts->setInterfaceMessage(true); } + $message = $this->mParser->transformMsg( $message, $popts ); + if ( $interface ) { $popts->setInterfaceMessage(false); } } } return $message; -- 2.20.1