From de13435a766a939c76ef32dec64459f8001c1deb Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 23 May 2004 05:32:20 +0000 Subject: [PATCH] fixed database error handling --- includes/Database.php | 8 +++++--- includes/OutputPage.php | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 4994f74eb5..db203fb7fb 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -174,13 +174,15 @@ class Database { } if ( false === $ret ) { + $error = mysql_error( $this->mConn ); + $errno = mysql_errno( $this->mConn ); if( $this->mIgnoreErrors ) { - wfDebug("SQL ERROR (ignored): " . mysql_error( $this->mConn ) . "\n"); + wfDebug("SQL ERROR (ignored): " . $error . "\n"); } else { - wfDebug("SQL ERROR: " . mysql_error( $this->mConn ) . "\n"); + wfDebug("SQL ERROR: " . $error . "\n"); if ( $this->mOut ) { // this calls wfAbruptExit() - $this->mOut->databaseError( $fname, $this ); + $this->mOut->databaseError( $fname, $sql, $error, $errno ); } } } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 7860a4228f..60f522130e 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -486,7 +486,7 @@ class OutputPage { $this->returnToMain(); # Flip back to the main page after 10 seconds. } - function databaseError( $fname, &$conn ) + function databaseError( $fname, $sql, $error, $errno ) { global $wgUser, $wgCommandLineMode; @@ -501,10 +501,10 @@ class OutputPage { $msg = wfMsgNoDB( "dberrortext" ); } - $msg = str_replace( "$1", htmlspecialchars( $conn->lastQuery() ), $msg ); + $msg = str_replace( "$1", htmlspecialchars( $sql ), $msg ); $msg = str_replace( "$2", htmlspecialchars( $fname ), $msg ); - $msg = str_replace( "$3", $conn->lastErrno(), $msg ); - $msg = str_replace( "$4", htmlspecialchars( $conn->lastError() ), $msg ); + $msg = str_replace( "$3", $errno, $msg ); + $msg = str_replace( "$4", htmlspecialchars( $error ), $msg ); if ( $wgCommandLineMode || !is_object( $wgUser )) { print "$msg\n"; -- 2.20.1