From 05703f122be250e0002ed5de399b972a81c2f039 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 26 Jun 2004 03:28:58 +0000 Subject: [PATCH] Nicer looking errors in command line mode --- includes/Database.php | 10 ++++++++-- includes/GlobalFunctions.php | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index a103e32e15..f382485813 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -157,7 +157,7 @@ class Database { # If errors are explicitly ignored, returns success function query( $sql, $fname = "" ) { - global $wgProfiling; + global $wgProfiling, $wgCommandLineMode; if ( $wgProfiling ) { # generalizeSQL will probably cut down the query to reasonable @@ -186,7 +186,13 @@ class Database { wfDebug("SQL ERROR (ignored): " . $error . "\n"); } else { wfDebug("SQL ERROR: " . $error . "\n"); - if ( $this->mOut ) { + if ( $wgCommandLineMode ) { + wfDebugDieBacktrace( "A database error has occurred\n" . + "Query: $sql\n" . + "Function: $fname\n" . + "Error: $errno $error\n" + ); + } elseif ( $this->mOut ) { // this calls wfAbruptExit() $this->mOut->databaseError( $fname, $sql, $error, $errno ); } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 08b916276e..dd5197d07d 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -370,15 +370,31 @@ function wfAbruptExit(){ } function wfDebugDieBacktrace( $msg = '' ) { + global $wgCommandLineMode; + if ( function_exists( 'debug_backtrace' ) ) { - $msg .= "\n

Backtrace:

\n