From e5614cea2c7f3e314d5215b32630031d4c59d0ef Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 4 May 2012 22:44:14 +0200 Subject: [PATCH] Show Highest expansion depth in limit report With 1.20wmf2 we get a tracking category with all the problem pages, seeing the limit for a page is a helpful information than Change-Id: I1916e5fa6de06b923a01cf1f0ca9362287a9fd70 --- includes/parser/Parser.php | 4 +++- includes/parser/Preprocessor_DOM.php | 3 +++ includes/parser/Preprocessor_Hash.php | 3 +++ includes/parser/Preprocessor_HipHop.hphp | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index d5868a71d0..6d6270add5 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -161,7 +161,7 @@ class Parser { var $mLinkHolders; var $mLinkID; - var $mIncludeSizes, $mPPNodeCount, $mDefaultSort; + var $mIncludeSizes, $mPPNodeCount, $mHighestExpansionDepth, $mDefaultSort; var $mTplExpandCache; # empty-frame expansion cache var $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores; var $mExpensiveFunctionCount; # number of expensive parser function calls @@ -304,6 +304,7 @@ class Parser { 'arg' => 0, ); $this->mPPNodeCount = 0; + $this->mHighestExpansionDepth = 0; $this->mDefaultSort = false; $this->mHeadings = array(); $this->mDoubleUnderscores = array(); @@ -478,6 +479,7 @@ class Parser { "Preprocessor node count: {$this->mPPNodeCount}/{$this->mOptions->getMaxPPNodeCount()}\n" . "Post-expand include size: {$this->mIncludeSizes['post-expand']}/$max bytes\n" . "Template argument size: {$this->mIncludeSizes['arg']}/$max bytes\n". + "Highest expansion depth: {$this->mHighestExpansionDepth}/{$this->mOptions->getMaxPPExpandDepth()}\n". $PFreport; wfRunHooks( 'ParserLimitReport', array( $this, &$limitReport ) ); $text .= "\n\n"; diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 74a7164333..602d88fad0 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -989,6 +989,9 @@ class PPFrame_DOM implements PPFrame { } wfProfileIn( __METHOD__ ); ++$expansionDepth; + if ( $expansionDepth > $this->parser->mHighestExpansionDepth ) { + $this->parser->mHighestExpansionDepth = $expansionDepth; + } if ( $root instanceof PPNode_DOM ) { $root = $root->node; diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 587e8ac081..dc2d63a3bd 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -944,6 +944,9 @@ class PPFrame_Hash implements PPFrame { return 'Expansion depth limit exceeded'; } ++$expansionDepth; + if ( $expansionDepth > $this->parser->mHighestExpansionDepth ) { + $this->parser->mHighestExpansionDepth = $expansionDepth; + } $outStack = array( '', '' ); $iteratorStack = array( false, $root ); diff --git a/includes/parser/Preprocessor_HipHop.hphp b/includes/parser/Preprocessor_HipHop.hphp index 39c3319492..b30b096d89 100644 --- a/includes/parser/Preprocessor_HipHop.hphp +++ b/includes/parser/Preprocessor_HipHop.hphp @@ -1102,6 +1102,9 @@ class PPFrame_HipHop implements PPFrame { return 'Expansion depth limit exceeded'; } ++$expansionDepth; + if ( $expansionDepth > $this->parser->mHighestExpansionDepth ) { + $this->parser->mHighestExpansionDepth = $expansionDepth; + } $outStack = array( '', '' ); $iteratorStack = array( false, $root ); -- 2.20.1