r56878 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56877‎ | r56878 | r56879 >
Date:13:33, 24 September 2009
Author:thomasv
Status:ok (Comments)
Tags:todo 
Comment:
fix: Parser::replaceVariables() has a side effect
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -272,7 +272,13 @@
273273
274274 //links in ns-0. Only if mOptions exist
275275 if( $wgParser->mOptions ) {
 276+ # We use Parser::replaceVariables to expand templates
 277+ # However this method has a side effect on wgParser->mOutput->mTemplates,
 278+ # To avoid this, we instanciate a temporary ParserOutput object
 279+ $saved_output = $wgParser->mOutput;
 280+ $wgParser->mOutput = new ParserOutput;
276281 $rtext = $wgParser->replaceVariables( $text );
 282+ $wgParser->mOutput = $saved_output;
277283 $text_links_pattern = "/\[\[([^:\|]*?)(\|(.*?)|)\]\]/i";
278284 preg_match_all( $text_links_pattern, $rtext, $text_links, PREG_PATTERN_ORDER );
279285 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r59787create a fresh parser object, as suggested by brion in r56878thomasv14:14, 7 December 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   17:26, 24 September 2009

Probably better to do this by creating a fresh Parser object, but this is at least not worse than previous. :)

Status & tagging log