fixed database error handling
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 23 May 2004 05:32:20 +0000 (05:32 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 23 May 2004 05:32:20 +0000 (05:32 +0000)
includes/Database.php
includes/OutputPage.php

index 4994f74..db203fb 100644 (file)
@@ -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 );                             
                                }
                        }
                }
index 7860a42..60f5221 100644 (file)
@@ -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";