Start of bug 24853, killing off 'functional' parts of failfunction code. Seems when...
authorSam Reed <reedy@users.mediawiki.org>
Sun, 24 Oct 2010 20:48:48 +0000 (20:48 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 24 Oct 2010 20:48:48 +0000 (20:48 +0000)
includes/db/Database.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMssql.php
includes/db/DatabasePostgres.php
includes/db/DatabaseSqlite.php
includes/db/LoadBalancer.php

index 595ceab..67979b8 100644 (file)
@@ -235,14 +235,6 @@ abstract class DatabaseBase implements DatabaseType {
                return $this->getServerVersion();
        }
 
-       /**
-        * Fail function, takes a Database as a parameter
-        * Set to false for default, 1 for ignore errors
-        */
-       function failFunction( $function = null ) {
-               return wfSetVar( $this->mFailFunction, $function );
-       }
-
        /**
         * Boolean, controls output of large amounts of debug information
         */
@@ -500,8 +492,6 @@ abstract class DatabaseBase implements DatabaseType {
                if ( !isset( $wgOut ) ) {
                        $wgOut = null;
                }
-
-               $this->mFailFunction = $failFunction;
                $this->mFlags = $flags;
 
                if ( $this->mFlags & DBO_DEFAULT ) {
@@ -589,16 +579,8 @@ abstract class DatabaseBase implements DatabaseType {
                        $error = $myError;
                }
 
-               if ( $this->mFailFunction ) {
-                       # Legacy error handling method
-                       if ( !is_int( $this->mFailFunction ) ) {
-                               $ff = $this->mFailFunction;
-                               $ff( $this, $error );
-                       }
-               } else {
-                       # New method
-                       throw new DBConnectionError( $this, $error );
-               }
+               # New method
+               throw new DBConnectionError( $this, $error );
        }
 
        /**
index 2e6f8c1..5fbf81c 100644 (file)
@@ -273,7 +273,6 @@ class DatabaseIbm_db2 extends DatabaseBase {
                        $wgOut = null;
                }
                $this->mOut =& $wgOut;
-               $this->mFailFunction = $failFunction;
                $this->mFlags = DBO_TRX | $flags;
 
                if ( $schema == self::USE_GLOBAL ) {
index 7acb36c..d44bf32 100644 (file)
@@ -20,10 +20,8 @@ class DatabaseMssql extends DatabaseBase {
        function __construct( $server = false, $user = false, $password = false, $dbName = false,
                $failFunction = false, $flags = 0 )
        {
-               $this->mFailFunction = $failFunction;
                $this->mFlags = $flags;
                $this->open( $server, $user, $password, $dbName );
-
        }
 
        function cascadingDeletes() {
index a694734..ddf2fdb 100644 (file)
@@ -103,7 +103,6 @@ class DatabasePostgres extends DatabaseBase {
        function __construct( $server = false, $user = false, $password = false, $dbName = false,
                $failFunction = false, $flags = 0 )
        {
-               $this->mFailFunction = $failFunction;
                $this->mFlags = $flags;
                $this->open( $server, $user, $password, $dbName );
        }
@@ -192,11 +191,7 @@ class DatabasePostgres extends DatabaseBase {
                        wfDebug( "DB connection error\n" );
                        wfDebug( "Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n" );
                        wfDebug( $this->lastError() . "\n" );
-                       if ( !$this->mFailFunction ) {
-                               throw new DBConnectionError( $this, $phpError );
-                       } else {
-                               return false;
-                       }
+                       throw new DBConnectionError( $this, $phpError );
                }
 
                $this->mOpened = true;
index 103744a..1313252 100644 (file)
@@ -25,7 +25,6 @@ class DatabaseSqlite extends DatabaseBase {
         */
        function __construct( $server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0 ) {
                global $wgSharedDB;
-               $this->mFailFunction = $failFunction;
                $this->mFlags = $flags;
                $this->mName = $dbName;
 
@@ -80,12 +79,7 @@ class DatabaseSqlite extends DatabaseBase {
                }
                if ( !$this->mConn ) {
                        wfDebug( "DB connection error: $err\n" );
-                       if ( !$this->mFailFunction ) {
-                               throw new DBConnectionError( $this, $err );
-                       } else {
-                               return false;
-                       }
-
+                       throw new DBConnectionError( $this, $err );
                }
                $this->mOpened = !!$this->mConn;
                # set error codes only, don't raise exceptions
index 1977390..e94ebb2 100644 (file)
@@ -35,11 +35,6 @@ class LoadBalancer {
                }
                $this->mServers = $params['servers'];
 
-               if ( isset( $params['failFunction'] ) ) {
-                       $this->mFailFunction = $params['failFunction'];
-               } else {
-                       $this->mFailFunction = false;
-               }
                if ( isset( $params['waitTimeout'] ) ) {
                        $this->mWaitTimeout = $params['waitTimeout'];
                } else {
@@ -671,19 +666,9 @@ class LoadBalancer {
                        // No last connection, probably due to all servers being too busy
                        wfLogDBError( "LB failure with no last connection\n" );
                        $conn = new Database;
-                       if ( $this->mFailFunction ) {
-                               $conn->failFunction( $this->mFailFunction );
-                               $conn->reportConnectionError( $this->mLastError );
-                       } else {
-                               // If all servers were busy, mLastError will contain something sensible
-                               throw new DBConnectionError( $conn, $this->mLastError );
-                       }
+                       // If all servers were busy, mLastError will contain something sensible
+                       throw new DBConnectionError( $conn, $this->mLastError );
                } else {
-                       if ( $this->mFailFunction ) {
-                               $conn->failFunction( $this->mFailFunction );
-                       } else {
-                               $conn->failFunction( false );
-                       }
                        $server = $conn->getProperty( 'mServer' );
                        wfLogDBError( "Connection error: {$this->mLastError} ({$server})\n" );
                        $conn->reportConnectionError( "{$this->mLastError} ({$server})" );