From: Platonides Date: Thu, 5 Aug 2010 18:43:49 +0000 (+0000) Subject: Make intfunction go accross the ParserOptions. X-Git-Tag: 1.31.0-rc.0~35696 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=e1e71bde41630797cdb682deed1fd5f7be9431dd;p=lhc%2Fweb%2Fwiklou.git Make intfunction go accross the ParserOptions. Things like calling setUserLang( true ) to use the content language are unsupported and shouldn't be done. --- diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 58c57714a8..85873c55e6 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -81,7 +81,7 @@ class CoreParserFunctions { static function intFunction( $parser, $part1 = '' /*, ... */ ) { if ( strval( $part1 ) !== '' ) { $args = array_slice( func_get_args(), 2 ); - $message = wfMsgGetKey( $part1, true, false, false ); + $message = wfMsgGetKey( $part1, true, $parser->mOptions->getUserLang(), false ); $message = wfMsgReplaceArgs( $message, $args ); $message = $parser->replaceVariables( $message ); // like $wgMessageCache->transform() return $message; diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 5e4dec5f5d..4f2e5f15a1 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -29,6 +29,8 @@ class ParserOptions { var $mEnableLimitReport; # Enable limit report in an HTML comment on output var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc. var $mExternalLinkTarget; # Target attribute for external links + var $mMath; # User math preference (as integer) + var $mUserLang; # Language code of the User language. var $mUser; # Stored user object, just used to initialise the skin var $mIsPreview; # Parsing the page for a "preview" operation @@ -85,6 +87,13 @@ class ParserOptions { return $this->mTimestamp; } + # You shouldn't use this. Really. $parser->getFunctionLang() is all you need. + # Using this fragments the cache and is discouraged. Yes, {{int: }} uses this, + # producing inconsistent tables (Bug 14404). + function getUserLang() { + return $this->mUserLang; + } + function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); } function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic, $x ); } function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages, $x ); } @@ -108,6 +117,7 @@ class ParserOptions { function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); } function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); } function setMath( $x ) { return wfSetVar( $this->mMath, $x ); } + function setUserLang( $x ) { return wfSetVar( $this->mUserLang, $x ); } function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview, $x ); } function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview, $x ); } @@ -132,7 +142,7 @@ class ParserOptions { global $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages; global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize; global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures; - global $wgExternalLinkTarget; + global $wgExternalLinkTarget, $wgLang; wfProfileIn( __METHOD__ ); @@ -172,6 +182,7 @@ class ParserOptions { $this->mCleanSignatures = $wgCleanSignatures; $this->mExternalLinkTarget = $wgExternalLinkTarget; $this->mMath = $user->getOption( 'math' ); + $this->mUserLang = $wgLang->getCode(); $this->mIsPreview = false; $this->mIsSectionPreview = false;