From 8949e26400014f3187c97d7ade280235776a9da8 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 2 Feb 2006 13:42:50 +0000 Subject: [PATCH] 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. --- includes/Parser.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 13b5f2e188..2b89d92679 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -99,16 +99,16 @@ class Parser var $mOutput, $mAutonumber, $mDTopen, $mStripState = array(); var $mVariables, $mIncludeCount, $mArgStack, $mLastSection, $mInPre; var $mInterwikiLinkHolders, $mLinkHolders, $mUniqPrefix; + var $mTemplates, // cache of already loaded templates, avoids + // multiple SQL queries for the same string + $mTemplatePath; // stores an unsorted hash of all the templates already loaded + // in this path. Used for loop detection. - # Temporary: + # Temporary + # These are variables reset at least once per parse regardless of $clearState var $mOptions, // ParserOptions object $mTitle, // Title context, used for self-link rendering and similar things $mOutputType, // Output type, one of the OT_xxx constants - $mTemplates, // cache of already loaded templates, avoids - // multiple SQL queries for the same string - $mTemplatePath, // stores an unsorted hash of all the templates already loaded - // in this path. Used for loop detection. - $mIWTransData = array(), $mRevisionId; // ID to display in {{REVISIONID}} tags /**#@-*/ @@ -119,8 +119,6 @@ class Parser * @access public */ function Parser() { - $this->mTemplates = array(); - $this->mTemplatePath = array(); $this->mTagHooks = array(); $this->clearState(); } @@ -154,6 +152,10 @@ class Parser $this->mRevisionId = null; $this->mUniqPrefix = 'UNIQ' . Parser::getRandomString(); + # Clear these on every parse, bug 4549 + $this->mTemplates = array(); + $this->mTemplatePath = array(); + wfRunHooks( 'ParserClearState', array( &$this ) ); } @@ -829,18 +831,10 @@ class Parser $text = $this->doTableStuff( $text ); $text = $this->formatHeadings( $text, $isMain ); - $regex = '//'; - $text = preg_replace_callback($regex, array(&$this, 'scarySubstitution'), $text); - wfProfileOut( $fname ); return $text; } - function scarySubstitution($matches) { -# return "[[".$matches[0]."]]"; - return $this->mIWTransData[(int)$matches[0]]; - } - /** * Replace special strings like "ISBN xxx" and "RFC xxx" with * magic external links. -- 2.20.1