X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2FDatabase.php;h=8c06ef41365f7ef60c31d9227e94669103d3aff4;hb=08f105e2d93bf6f2be0d7dc8d6017b41ec6ad3b0;hp=8288e65201aeed80bda3604dcde6a12d40f02378;hpb=63dbc0aba243c7dcaa820220c2cb1aa2cc91eca1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/Database.php b/includes/db/Database.php index 8288e65201..8c06ef4136 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -806,7 +806,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * database. Example uses in core: * @see LoadBalancer::reallyOpenConnection() * @see ForeignDBRepo::getMasterDB() - * @see WebInstaller_DBConnect::execute() + * @see WebInstallerDBConnect::execute() * * @since 1.18 * @@ -926,7 +926,6 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { if ( count( $this->mTrxIdleCallbacks ) ) { // sanity throw new MWException( "Transaction idle callbacks still pending." ); } - $this->mOpened = false; if ( $this->mConn ) { if ( $this->trxLevel() ) { if ( !$this->mTrxAutomatic ) { @@ -937,13 +936,14 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { $this->commit( __METHOD__, 'flush' ); } - $ret = $this->closeConnection(); + $closed = $this->closeConnection(); $this->mConn = false; - - return $ret; } else { - return true; + $closed = true; } + $this->mOpened = false; + + return $closed; } /** @@ -1054,7 +1054,8 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { # Keep track of whether the transaction has write queries pending if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $this->isWriteQuery( $sql ) ) { $this->mTrxDoneWrites = true; - Profiler::instance()->transactionWritingIn( $this->mServer, $this->mDBname ); + $id = spl_object_hash( $this ); + Profiler::instance()->transactionWritingIn( $this->mServer, $this->mDBname, $id ); } $queryProf = ''; @@ -3410,11 +3411,17 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { $this->runOnTransactionPreCommitCallbacks(); $this->doCommit( $fname ); if ( $this->mTrxDoneWrites ) { - Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname ); + $id = spl_object_hash( $this ); + Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname, $id ); } $this->runOnTransactionIdleCallbacks(); } + # Avoid fatals if close() was called + if ( !$this->isOpen() ) { + throw new DBUnexpectedError( $this, "DB connection was already closed." ); + } + $this->doBegin( $fname ); $this->mTrxFname = $fname; $this->mTrxDoneWrites = false; @@ -3473,10 +3480,16 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } } + # Avoid fatals if close() was called + if ( !$this->isOpen() ) { + throw new DBUnexpectedError( $this, "DB connection was already closed." ); + } + $this->runOnTransactionPreCommitCallbacks(); $this->doCommit( $fname ); if ( $this->mTrxDoneWrites ) { - Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname ); + $id = spl_object_hash( $this ); + Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname, $id ); } $this->runOnTransactionIdleCallbacks(); } @@ -3522,12 +3535,18 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } } + # Avoid fatals if close() was called + if ( !$this->isOpen() ) { + throw new DBUnexpectedError( $this, "DB connection was already closed." ); + } + $this->doRollback( $fname ); $this->mTrxIdleCallbacks = array(); // cancel $this->mTrxPreCommitCallbacks = array(); // cancel $this->mTrxAtomicLevels = new SplStack; if ( $this->mTrxDoneWrites ) { - Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname ); + $id = spl_object_hash( $this ); + Profiler::instance()->transactionWritingOut( $this->mServer, $this->mDBname, $id ); } }