Fixed the expansion depth limit feature, broken by Brion in r32550. This may be the...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 23 Oct 2008 14:40:10 +0000 (14:40 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 23 Oct 2008 14:40:10 +0000 (14:40 +0000)
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php

index 6ba48e8..f0f5a80 100644 (file)
@@ -770,6 +770,7 @@ class PPFrame_DOM implements PPFrame {
 
        /**
         * Recursion depth of this frame, top = 0
+        * Note that this is NOT the same as expansion depth in expand()
         */
        var $depth;
 
@@ -826,7 +827,7 @@ class PPFrame_DOM implements PPFrame {
        }
 
        function expand( $root, $flags = 0 ) {
-               static $depth = 0;
+               static $expansionDepth = 0;
                if ( is_string( $root ) ) {
                        return $root;
                }
@@ -837,10 +838,10 @@ class PPFrame_DOM implements PPFrame {
                        return '<span class="error">Node-count limit exceeded</span>';
                }
 
-               if ( $depth > $this->parser->mOptions->mMaxPPExpandDepth ) {
+               if ( $expansionDepth > $this->parser->mOptions->mMaxPPExpandDepth ) {
                        return '<span class="error">Expansion depth limit exceeded</span>';
                }
-               ++$depth;
+               ++$expansionDepth;
 
                if ( $root instanceof PPNode_DOM ) {
                        $root = $root->node;
@@ -1029,7 +1030,7 @@ class PPFrame_DOM implements PPFrame {
                                }
                        }
                }
-               --$depth;
+               --$expansionDepth;
                wfProfileOut( __METHOD__ );
                return $outStack[0];
        }
index 867878d..5473286 100644 (file)
@@ -758,6 +758,7 @@ class PPFrame_Hash implements PPFrame {
 
        /**
         * Recursion depth of this frame, top = 0
+        * Note that this is NOT the same as expansion depth in expand()
         */
        var $depth;
 
@@ -810,6 +811,7 @@ class PPFrame_Hash implements PPFrame {
        }
 
        function expand( $root, $flags = 0 ) {
+               static $expansionDepth = 0;
                if ( is_string( $root ) ) {
                        return $root;
                }
@@ -818,10 +820,10 @@ class PPFrame_Hash implements PPFrame {
                {
                        return '<span class="error">Node-count limit exceeded</span>';
                }
-               if ( $this->depth > $this->parser->mOptions->mMaxPPExpandDepth ) {
+               if ( $expansionDepth > $this->parser->mOptions->mMaxPPExpandDepth ) {
                        return '<span class="error">Expansion depth limit exceeded</span>';
                }
-               ++$this->depth;
+               ++$expansionDepth;
 
                $outStack = array( '', '' );
                $iteratorStack = array( false, $root );
@@ -974,7 +976,7 @@ class PPFrame_Hash implements PPFrame {
                                }
                        }
                }
-               --$this->depth;
+               --$expansionDepth;
                return $outStack[0];
        }