From 1e987d7c193c7e8473b1720c110b665a36e79b7a Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 8 Jun 2006 07:05:57 +0000 Subject: [PATCH] Made wfDebugDieBacktrace() throw an exception: roughly backwards-compatible behaviour for the benefit of the extensions which use this function. Marked wfAbruptExit() and wfErrorExit() obsolete, they're only called from one extension as far as I know (gis), and nowhere from within the core. --- includes/GlobalFunctions.php | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index ed412590b7..bab5d354b6 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -599,6 +599,8 @@ function wfMsgExt( $key, $options ) { /** * Just like exit() but makes a note of it. * Commits open transactions except if the error parameter is set + * + * @obsolete Please return control to the caller or throw an exception */ function wfAbruptExit( $error = false ){ global $wgLoadBalancer; @@ -629,7 +631,7 @@ function wfAbruptExit( $error = false ){ } /** - * @todo document + * @obsolete Please return control the caller or throw an exception */ function wfErrorExit() { wfAbruptExit( true ); @@ -646,26 +648,13 @@ function wfDie( $msg='' ) { } /** - * Die with a backtrace - * This is meant as a debugging aid to track down where bad data comes from. - * Shouldn't be used in production code except maybe in "shouldn't happen" areas. + * Throw a debugging exception. This function previously once exited the process, + * but now throws an exception instead, with similar results. * * @param string $msg Message shown when dieing. */ function wfDebugDieBacktrace( $msg = '' ) { - global $wgCommandLineMode; - - $backtrace = wfBacktrace(); - if ( $backtrace !== false ) { - if ( $wgCommandLineMode ) { - $msg .= "\nBacktrace:\n$backtrace"; - } else { - $msg .= "\n

Backtrace:

\n$backtrace"; - } - } - echo $msg; - echo wfReportTime()."\n"; - die( 1 ); + throw new MWException( $msg ); } /** -- 2.20.1