From: umherirrender Date: Fri, 4 May 2012 18:56:28 +0000 (+0200) Subject: Use $wgExpensiveParserFunctionLimit over ParserOptions X-Git-Tag: 1.31.0-rc.0~23723^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=3dd5c97e85370d2c573802272d94d7089f8ffa2c;p=lhc%2Fweb%2Fwiklou.git Use $wgExpensiveParserFunctionLimit over ParserOptions This allows extensions to set the value Change-Id: I4a935a00fe02a2bb88a14942e5e3ec6f4e5e833e --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index d5868a71d0..cc47db50df 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -462,9 +462,12 @@ class Parser { array_values( $tidyregs ), $text ); } - global $wgExpensiveParserFunctionLimit; - if ( $this->mExpensiveFunctionCount > $wgExpensiveParserFunctionLimit ) { - $this->limitationWarn( 'expensive-parserfunction', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit ); + + if ( $this->mExpensiveFunctionCount > $this->mOptions->getExpensiveParserFunctionLimit() ) { + $this->limitationWarn( 'expensive-parserfunction', + $this->mExpensiveFunctionCount, + $this->mOptions->getExpensiveParserFunctionLimit() + ); } wfRunHooks( 'ParserAfterTidy', array( &$this, &$text ) ); @@ -472,7 +475,7 @@ class Parser { # Information on include size limits, for the benefit of users who try to skirt them if ( $this->mOptions->getEnableLimitReport() ) { $max = $this->mOptions->getMaxIncludeSize(); - $PFreport = "Expensive parser function count: {$this->mExpensiveFunctionCount}/$wgExpensiveParserFunctionLimit\n"; + $PFreport = "Expensive parser function count: {$this->mExpensiveFunctionCount}/{$this->mOptions->getExpensiveParserFunctionLimit()}\n"; $limitReport = "NewPP limit report\n" . "Preprocessor node count: {$this->mPPNodeCount}/{$this->mOptions->getMaxPPNodeCount()}\n" . @@ -3828,12 +3831,8 @@ class Parser { * @return Boolean: false if the limit has been exceeded */ function incrementExpensiveFunctionCount() { - global $wgExpensiveParserFunctionLimit; $this->mExpensiveFunctionCount++; - if ( $this->mExpensiveFunctionCount <= $wgExpensiveParserFunctionLimit ) { - return true; - } - return false; + return $this->mExpensiveFunctionCount <= $this->mOptions->getExpensiveParserFunctionLimit(); } /** diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 650a1752a0..211fcd63cf 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -105,6 +105,11 @@ class ParserOptions { */ var $mMaxTemplateDepth; + /** + * Maximum number of calls per parse to expensive parser functions + */ + var $mExpensiveParserFunctionLimit; + /** * Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS */ @@ -216,6 +221,8 @@ class ParserOptions { function getMaxPPNodeCount() { return $this->mMaxPPNodeCount; } function getMaxPPExpandDepth() { return $this->mMaxPPExpandDepth; } function getMaxTemplateDepth() { return $this->mMaxTemplateDepth; } + /* @since 1.20 */ + function getExpensiveParserFunctionLimit() { return $this->mExpensiveParserFunctionLimit; } function getRemoveComments() { return $this->mRemoveComments; } function getTemplateCallback() { return $this->mTemplateCallback; } function getEnableLimitReport() { return $this->mEnableLimitReport; } @@ -301,6 +308,8 @@ class ParserOptions { function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize, $x ); } function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount, $x ); } function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth, $x ); } + /* @since 1.20 */ + function setExpensiveParserFunctionLimit( $x ) { return wfSetVar( $this->mExpensiveParserFunctionLimit, $x ); } function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments, $x ); } function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback, $x ); } function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport, $x ); } @@ -395,7 +404,7 @@ class ParserOptions { global $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages, $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize, $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, - $wgCleanSignatures, $wgExternalLinkTarget; + $wgCleanSignatures, $wgExternalLinkTarget, $wgExpensiveParserFunctionLimit; wfProfileIn( __METHOD__ ); @@ -409,6 +418,7 @@ class ParserOptions { $this->mMaxPPNodeCount = $wgMaxPPNodeCount; $this->mMaxPPExpandDepth = $wgMaxPPExpandDepth; $this->mMaxTemplateDepth = $wgMaxTemplateDepth; + $this->mExpensiveParserFunctionLimit = $wgExpensiveParserFunctionLimit; $this->mCleanSignatures = $wgCleanSignatures; $this->mExternalLinkTarget = $wgExternalLinkTarget;