# 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
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 );
}
}
function wfDebugDieBacktrace( $msg = '' ) {
+ global $wgCommandLineMode;
+
if ( function_exists( 'debug_backtrace' ) ) {
- $msg .= "\n<p>Backtrace:</p>\n<ul>\n";
+ if ( $wgCommandLineMode ) {
+ $msg .= "\nBacktrace:\n";
+ } else {
+ $msg .= "\n<p>Backtrace:</p>\n<ul>\n";
+ }
$backtrace = debug_backtrace();
foreach( $backtrace as $call ) {
$f = explode( DIRECTORY_SEPARATOR, $call['file'] );
$file = $f[count($f)-1];
- $msg .= '<li>' . $file . " line " . $call['line'] . ', in ';
+ if ( $wgCommandLineMode ) {
+ $msg .= "$file line {$call['line']}, in ";
+ } else {
+ $msg .= '<li>' . $file . " line " . $call['line'] . ', in ';
+ }
if( !empty( $call['class'] ) ) $msg .= $call['class'] . '::';
- $msg .= $call['function'] . "()</li>\n";
+ $msg .= $call['function'] . "()";
+
+ if ( $wgCommandLineMode ) {
+ $msg .= "\n";
+ } else {
+ $msg .= "</li>\n";
+ }
}
}
die( $msg );