* $wgDebugTidy feature
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 30 Nov 2007 12:26:12 +0000 (12:26 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 30 Nov 2007 12:26:12 +0000 (12:26 +0000)
* Fixed a bug in extractSections() -- inappropriate expansion of double-brace constructs causing a fatal error under some circumstances (reported by Nikerabbit, thanks)

includes/DefaultSettings.php
includes/Parser.php

index 9c8c726..56ae28b 100644 (file)
@@ -1884,6 +1884,12 @@ $wgTidyConf = $IP.'/includes/tidy.conf';
 $wgTidyOpts = '';
 $wgTidyInternal = extension_loaded( 'tidy' );
 
+/**
+ * Put tidy warnings in HTML comments
+ * Only works for internal tidy.
+ */
+$wgDebugTidy = false;
+
 /** See list of skins and their symbolic names in languages/Language.php */
 $wgDefaultSkin = 'monobook';
 
index e314fac..3374faa 100644 (file)
@@ -685,7 +685,7 @@ class Parser
         * @static
         */
        function internalTidy( $text ) {
-               global $wgTidyConf, $IP;
+               global $wgTidyConf, $IP, $wgDebugTidy;
                $fname = 'Parser::internalTidy';
                wfProfileIn( $fname );
 
@@ -699,6 +699,12 @@ class Parser
                } else {
                        $cleansource = tidy_get_output( $tidy );
                }
+               if ( $wgDebugTidy && $tidy->getStatus() > 0 ) {
+                       $cleansource .= "<!--\nTidy reports:\n" . 
+                               str_replace( '-->', '--&gt;', $tidy->errorBuffer ) . 
+                               "\n-->";
+               }
+
                wfProfileOut( $fname );
                return $cleansource;
        }
@@ -4956,7 +4962,7 @@ class Parser
                                        $curIndex++;
                                }
                                if ( $mode == 'replace' ) {
-                                       $outText .= $frame->expand( $node );
+                                       $outText .= $frame->expand( $node, 0, PPFrame::RECOVER_ORIG );
                                }
                                $node = $node->nextSibling;
                        }
@@ -4984,7 +4990,7 @@ class Parser
                                }
                        }
                        if ( $mode == 'get' ) {
-                               $outText .= $frame->expand( $node );
+                               $outText .= $frame->expand( $node, 0, PPFrame::RECOVER_ORIG );
                        }
                        $node = $node->nextSibling;
                } while ( $node );
@@ -4996,7 +5002,7 @@ class Parser
                        // stripped by the editor, so we need both newlines to restore the paragraph gap
                        $outText .= $newText . "\n\n";
                        while ( $node ) {
-                               $outText .= $frame->expand( $node );
+                               $outText .= $frame->expand( $node, 0, PPFrame::RECOVER_ORIG );
                                $node = $node->nextSibling;
                        }
                }
@@ -5218,6 +5224,7 @@ class PPFrame {
 
        const NO_ARGS = 1;
        const NO_TEMPLATES = 2;
+       const RECOVER_ORIG = 3;
 
        /**
         * Construct a new preprocessor frame.