Start of bug 24853, killing off 'functional' parts of failfunction code. Seems when the constructors start getting changed, it starts borking. Using this as a point of reversion/stashing
This commit is contained in:
parent
090e191b23
commit
16cded8b32
6 changed files with 6 additions and 53 deletions
|
|
@ -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,17 +579,9 @@ 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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a query writes to the DB.
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
$this->mOpened = true;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
$this->mOpened = !!$this->mConn;
|
||||
# set error codes only, don't raise exceptions
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
} 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})" );
|
||||
|
|
|
|||
Loading…
Reference in a new issue