From 92ba47064bfa928d0ed8c7257842dd74873c6c86 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 28 Jun 2011 19:46:23 +0000 Subject: [PATCH] * Remove Exception.php's reliance on wfDie(), as well as the awful constant MEDIAWIKI_INSTALL (holdover from old installer) * Rm checking for MEDIAWIKI_INSTALL in wfOut(), no codepath leads here from the installer anymore --- includes/Exception.php | 25 ++++++++++++++++--------- includes/GlobalFunctions.php | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/includes/Exception.php b/includes/Exception.php index 385c1928ed..8cce9a0e56 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -187,12 +187,8 @@ class MWException extends Exception { die( $hookResult ); } - $html = $this->getHTML(); - if ( defined( 'MEDIAWIKI_INSTALL' ) ) { - echo $html; - } else { - wfDie( $html ); - } + echo $this->getHTML(); + die(1); } } @@ -215,7 +211,7 @@ class MWException extends Exception { } static function isCommandLine() { - return !empty( $GLOBALS['wgCommandLineMode'] ) && !defined( 'MEDIAWIKI_INSTALL' ); + return !empty( $GLOBALS['wgCommandLineMode'] ); } } @@ -431,7 +427,7 @@ class MWExceptionHandler { if ( $cmdLine ) { self::printError( $message ); } else { - wfDie( nl2br( htmlspecialchars( $message ) ) ) . "\n"; + self::escapeEchoAndDie( $message ); } } } else { @@ -445,7 +441,7 @@ class MWExceptionHandler { if ( $cmdLine ) { self::printError( $message ); } else { - wfDie( nl2br( htmlspecialchars( $message ) ) ) . "\n"; + self::escapeEchoAndDie( $message ); } } } @@ -453,6 +449,7 @@ class MWExceptionHandler { /** * Print a message, if possible to STDERR. * Use this in command line mode only (see isCommandLine) + * @param $message String Failure text */ public static function printError( $message ) { # NOTE: STDERR may not be available, especially if php-cgi is used from the command line (bug #15602). @@ -464,6 +461,16 @@ class MWExceptionHandler { } } + /** + * Print a message after escaping it and converting newlines to
+ * Use this for non-command line failures + * @param $message String Failure text + */ + private static function escapeEchoAndDie( $message ) { + echo nl2br( htmlspecialchars( $message ) ) . "\n"; + die(1); + } + /** * Exception handler which simulates the appropriate catch() handling: * diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index bca5ca0cdc..c66b0e89c1 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3350,7 +3350,7 @@ function wfWaitForSlaves( $maxLag = false, $wiki = false ) { function wfOut( $s ) { wfDeprecated( __METHOD__ ); global $wgCommandLineMode; - if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) { + if ( $wgCommandLineMode ) { echo $s; } else { echo htmlspecialchars( $s ); -- 2.20.1