Send correct HTML when reporting a MWException object and the OuputPage object cannot...
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 28 Jun 2012 09:52:43 +0000 (11:52 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Fri, 6 Jul 2012 18:57:12 +0000 (20:57 +0200)
Currently only the body was sent, without doc type, <html>, <head> or <body> items.

Change-Id: I2d5cc3f69f55d0e1b212148f57f736f100bd2554

includes/Exception.php

index 502f2ad..6e1325f 100644 (file)
@@ -128,10 +128,10 @@ class MWException extends Exception {
                                '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
                                "</p>\n";
                } else {
-                       return 
+                       return
                                "<div class=\"errorbox\">" .
                                '[' . $this->getLogId() . '] ' .
-                               gmdate( 'Y-m-d H:i:s' ) . 
+                               gmdate( 'Y-m-d H:i:s' ) .
                                ": Fatal exception of type " . get_class( $this ) . "</div>\n" .
                                "<!-- Set \$wgShowExceptionDetails = true; " .
                                "at the bottom of LocalSettings.php to show detailed " .
@@ -213,13 +213,20 @@ class MWException extends Exception {
                        $wgOut->output();
                } else {
                        header( "Content-Type: text/html; charset=utf-8" );
+                       echo "<!doctype html>\n" .
+                               '<html><head>' .
+                               '<title>' . htmlspecialchars( $this->getPageTitle() ) . '</title>' .
+                               "</head><body>\n";
+
                        $hookResult = $this->runHooks( get_class( $this ) . "Raw" );
                        if ( $hookResult ) {
-                               die( $hookResult );
+                               echo $hookResult;
+                       } else {
+                               echo $this->getHTML();
                        }
 
-                       echo $this->getHTML();
-                       die(1);
+                       echo "</body></html>\n";
+                       die( 1 );
                }
        }