r88134 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88133‎ | r88134 | r88135 >
Date:07:16, 15 May 2011
Author:nikerabbit
Status:ok (Comments)
Tags:
Comment:
Fixed a bug in transformation where previous language could leak into later transformations in UI language. Not sure what do with userlang.
Modified paths:
  • /trunk/phase3/includes/cache/MessageCache.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -137,7 +137,7 @@
138138 function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); }
139139 function setSkin( $x ) { $this->mSkin = $x; }
140140 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage, $x); }
141 - function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage, $x); }
 141+ function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage, $x, true ); }
142142 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize, $x ); }
143143 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount, $x ); }
144144 function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth, $x ); }
Index: trunk/phase3/includes/cache/MessageCache.php
@@ -761,11 +761,12 @@
762762 $popts = $this->getParserOptions();
763763 $popts->setInterfaceMessage( $interface );
764764 $popts->setTargetLanguage( $language );
765 - $popts->setUserLang( $language );
766765
 766+ $userlang = $popts->setUserLang( $language );
767767 $this->mInParser = true;
768768 $message = $parser->transformMsg( $message, $popts, $title );
769769 $this->mInParser = false;
 770+ $popts->setUserLang( $userlang );
770771 }
771772 return $message;
772773 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r91526* MFT r88134: Fixed a bug in transformation where previous language could lea...tstarling05:44, 6 July 2011
r92328REL1_18 MFT r79056, r80612, r81499, r87627, r87628, r87630, r87998, r88134, r...reedy22:46, 15 July 2011

Comments

#Comment by Nikerabbit (talk | contribs)   07:18, 15 May 2011

Please review and backport as appropriate.

#Comment by Tim Starling (talk | contribs)   05:38, 6 July 2011

Why would any of those set functions need $force = false? You know I don't like boolean parameters, I'd rather see a new function introduced that does the job of unconditionally setting a reference and returning the old value, so that the calling code can be readable.

#Comment by Nikerabbit (talk | contribs)   07:22, 6 July 2011

You mean dropping wfSerVar and doing it manually?

#Comment by Tim Starling (talk | contribs)   07:37, 6 July 2011

That would work too, but I was thinking more like

function wfSetAndReturnOld( &$ref, $newValue ) {
   $old = $ref;
   $ref = $newValue;
   return $old;
}

Then use that everywhere except in the combined accessor/mutator functions that wfSetVar() was intended for.

Status & tagging log