X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fparser%2FPreprocessor_DOM.php;h=7cb91da58816eba29fce706ada1ff78187a5fabb;hb=978bb31c5ec29c3e4788ea83735c88dd66e98844;hp=468802d4ca3843ded13a8980ee633ca1a709909d;hpb=f96e5c5eecd383bb816bb79482af4baf5ceee13a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 468802d4ca..7cb91da588 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -110,7 +110,7 @@ class Preprocessor_DOM implements Preprocessor { * Preprocess some wikitext and return the document tree. * This is the ghost of Parser::replace_variables(). * - * @param $text String: the text to parse + * @param string $text the text to parse * @param $flags Integer: bitwise combination of: * Parser::PTD_FOR_INCLUSION Handle "" and "" as if the text is being * included. Default is to assume a direct page view. @@ -169,6 +169,10 @@ class Preprocessor_DOM implements Preprocessor { $this->parser->mGeneratedPPNodeCount += substr_count( $xml, '<' ); $max = $this->parser->mOptions->getMaxGeneratedPPNodeCount(); if ( $this->parser->mGeneratedPPNodeCount > $max ) { + if ( $cacheable ) { + wfProfileOut( __METHOD__ . '-cacheable' ); + } + wfProfileOut( __METHOD__ ); throw new MWException( __METHOD__ . ': generated node count limit exceeded' ); } @@ -183,6 +187,11 @@ class Preprocessor_DOM implements Preprocessor { // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep $result = $dom->loadXML( $xml, 1 << 19 ); if ( !$result ) { + wfProfileOut( __METHOD__ . '-loadXML' ); + if ( $cacheable ) { + wfProfileOut( __METHOD__ . '-cacheable' ); + } + wfProfileOut( __METHOD__ ); throw new MWException( __METHOD__ . ' generated invalid XML' ); } } @@ -397,7 +406,7 @@ class Preprocessor_DOM implements Preprocessor { if ( $stack->top ) { $part = $stack->top->getCurrentPart(); - if ( !(isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 )) { + if ( !( isset( $part->commentEnd ) && $part->commentEnd == $wsStart - 1 ) ) { $part->visualEnd = $wsStart; } // Else comments abutting, no change in visual end @@ -522,7 +531,7 @@ class Preprocessor_DOM implements Preprocessor { if ( $equalsLength > 0 ) { if ( $searchStart - $equalsLength == $piece->startPos ) { // This is just a single string of equals signs on its own line - // Replicate the doHeadings behaviour /={count}(.+)={count}/ + // Replicate the doHeadings behavior /={count}(.+)={count}/ // First find out how many equals signs there really are (don't stop at 6) $count = $equalsLength; if ( $count < 3 ) { @@ -746,7 +755,7 @@ class PPDStack { $class = $this->elementClass; $this->stack[] = new $class( $data ); } - $this->top = $this->stack[ count( $this->stack ) - 1 ]; + $this->top = $this->stack[count( $this->stack ) - 1]; $this->accum =& $this->top->getAccum(); } @@ -757,7 +766,7 @@ class PPDStack { $temp = array_pop( $this->stack ); if ( count( $this->stack ) ) { - $this->top = $this->stack[ count( $this->stack ) - 1 ]; + $this->top = $this->stack[count( $this->stack ) - 1]; $this->accum =& $this->top->getAccum(); } else { $this->top = self::$false; @@ -911,7 +920,6 @@ class PPFrame_DOM implements PPFrame { */ var $depth; - /** * Construct a new preprocessor frame. * @param $preprocessor Preprocessor The parent preprocessor @@ -1015,11 +1023,13 @@ class PPFrame_DOM implements PPFrame { while ( count( $iteratorStack ) > 1 ) { $level = count( $outStack ) - 1; - $iteratorNode =& $iteratorStack[ $level ]; + $iteratorNode =& $iteratorStack[$level]; $out =& $outStack[$level]; $index =& $indexStack[$level]; - if ( $iteratorNode instanceof PPNode_DOM ) $iteratorNode = $iteratorNode->node; + if ( $iteratorNode instanceof PPNode_DOM ) { + $iteratorNode = $iteratorNode->node; + } if ( is_array( $iteratorNode ) ) { if ( $index >= count( $iteratorNode ) ) { @@ -1149,9 +1159,7 @@ class PPFrame_DOM implements PPFrame { # Insert a heading marker only for children of # This is to stop extractSections from going over multiple tree levels - if ( $contextNode->parentNode->nodeName == 'root' - && $this->parser->ot['html'] ) - { + if ( $contextNode->parentNode->nodeName == 'root' && $this->parser->ot['html'] ) { # Insert heading index marker $headingIndex = $contextNode->getAttribute( 'i' ); $titleText = $this->title->getPrefixedDBkey();