r12938 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12937‎ | r12938 | r12939 >
Date:13:42, 2 February 2006
Author:timstarling
Status:old
Tags:
Comment:
Bug 4549. "Temporary" means that it's cleared in parse() or some other frequently-called member function, which those two variables clearly weren't. They were in fact persistent. They should have been state variables. Also removed obsolete and unused transclusion code, which would have suffered the same problem if it was used.
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -99,16 +99,16 @@
100100 var $mOutput, $mAutonumber, $mDTopen, $mStripState = array();
101101 var $mVariables, $mIncludeCount, $mArgStack, $mLastSection, $mInPre;
102102 var $mInterwikiLinkHolders, $mLinkHolders, $mUniqPrefix;
 103+ var $mTemplates, // cache of already loaded templates, avoids
 104+ // multiple SQL queries for the same string
 105+ $mTemplatePath; // stores an unsorted hash of all the templates already loaded
 106+ // in this path. Used for loop detection.
103107
104 - # Temporary:
 108+ # Temporary
 109+ # These are variables reset at least once per parse regardless of $clearState
105110 var $mOptions, // ParserOptions object
106111 $mTitle, // Title context, used for self-link rendering and similar things
107112 $mOutputType, // Output type, one of the OT_xxx constants
108 - $mTemplates, // cache of already loaded templates, avoids
109 - // multiple SQL queries for the same string
110 - $mTemplatePath, // stores an unsorted hash of all the templates already loaded
111 - // in this path. Used for loop detection.
112 - $mIWTransData = array(),
113113 $mRevisionId; // ID to display in {{REVISIONID}} tags
114114
115115 /**#@-*/
@@ -119,8 +119,6 @@
120120 * @access public
121121 */
122122 function Parser() {
123 - $this->mTemplates = array();
124 - $this->mTemplatePath = array();
125123 $this->mTagHooks = array();
126124 $this->clearState();
127125 }
@@ -154,6 +152,10 @@
155153 $this->mRevisionId = null;
156154 $this->mUniqPrefix = 'UNIQ' . Parser::getRandomString();
157155
 156+ # Clear these on every parse, bug 4549
 157+ $this->mTemplates = array();
 158+ $this->mTemplatePath = array();
 159+
158160 wfRunHooks( 'ParserClearState', array( &$this ) );
159161 }
160162
@@ -829,18 +831,10 @@
830832 $text = $this->doTableStuff( $text );
831833 $text = $this->formatHeadings( $text, $isMain );
832834
833 - $regex = '/<!--IW_TRANSCLUDE (\d+)-->/';
834 - $text = preg_replace_callback($regex, array(&$this, 'scarySubstitution'), $text);
835 -
836835 wfProfileOut( $fname );
837836 return $text;
838837 }
839838
840 - function scarySubstitution($matches) {
841 -# return "[[".$matches[0]."]]";
842 - return $this->mIWTransData[(int)$matches[0]];
843 - }
844 -
845839 /**
846840 * Replace special strings like "ISBN xxx" and "RFC xxx" with
847841 * magic external links.

Status & tagging log