r10665 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10664‎ | r10665 | r10666 >
Date:15:28, 20 August 2005
Author:timstarling
Status:old
Tags:
Comment:
Fixed odd breakage of templates involving '<span class="{{foo}}">{{bar}}</span>'. {{bar}} was expanded without any arguments passed from the parent page. The problem was $this->mAssocArgs being overwritten by the call to replaceVariables() from within Sanitizer::removeHTMLtags(), and thus subtly corrupted for the subsequent call from braceSubstitution() itself. I've forgotten why I made that a class member in the first place, but making it a local instead doesn't break any parser tests, so it's a sufficient solution as far as I'm concerned.
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -111,7 +111,6 @@
112112 // in this path. Used for loop detection.
113113
114114 var $mIWTransData = array();
115 - var $mAssocArgs = array();
116115
117116 /**#@-*/
118117
@@ -2246,7 +2245,6 @@
22472246 if ( $this->mOutputType == OT_HTML && !$found ) {
22482247 $text = '[['.$title->getPrefixedText().']]';
22492248 $found = true;
2250 - }
22512249
22522250 # Template cache array insertion
22532251 if( $found ) {
@@ -2262,12 +2260,12 @@
22632261 $text = wfEscapeWikiText( $text );
22642262 } elseif ( ($this->mOutputType == OT_HTML || $this->mOutputType == OT_WIKI) && $found && !$noparse) {
22652263 # Clean up argument array
2266 - $this->mAssocArgs = array();
 2264+ $assocArgs = array();
22672265 $index = 1;
22682266 foreach( $args as $arg ) {
22692267 $eqpos = strpos( $arg, '=' );
22702268 if ( $eqpos === false ) {
2271 - $this->mAssocArgs[$index++] = $arg;
 2269+ $assocArgs[$index++] = $arg;
22722270 } else {
22732271 $name = trim( substr( $arg, 0, $eqpos ) );
22742272 $value = trim( substr( $arg, $eqpos+1 ) );
@@ -2275,7 +2273,7 @@
22762274 $value = '';
22772275 }
22782276 if ( $name !== false ) {
2279 - $this->mAssocArgs[$name] = $value;
 2277+ $assocArgs[$name] = $value;
22802278 }
22812279 }
22822280 }
@@ -2289,9 +2287,9 @@
22902288 $text = strtr( $text, array( '<includeonly>' => '' , '</includeonly>' => '' ) );
22912289 # Strip <nowiki>, <pre>, etc.
22922290 $text = $this->strip( $text, $this->mStripState );
2293 - $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'replaceVariables' ), $this->mAssocArgs );
 2291+ $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'replaceVariables' ), $assocArgs );
22942292 }
2295 - $text = $this->replaceVariables( $text, $this->mAssocArgs );
 2293+ $text = $this->replaceVariables( $text, $assocArgs );
22962294
22972295 # Resume the link cache and register the inclusion as a link
22982296 if ( $this->mOutputType == OT_HTML && !is_null( $title ) ) {

Status & tagging log