Separate language generation from outputPage
[lhc/web/wiklou.git] / includes / parser / Preprocessor_DOM.php
index d0c57ab..7cb91da 100644 (file)
@@ -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
@@ -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;
@@ -1014,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 ) ) {
@@ -1148,9 +1159,7 @@ class PPFrame_DOM implements PPFrame {
 
                                        # Insert a heading marker only for <h> children of <root>
                                        # 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();