Merge "Avoid fatals in begin/commit/rollback if close() was called"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 19 May 2014 04:20:00 +0000 (04:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 19 May 2014 04:20:00 +0000 (04:20 +0000)
includes/db/Database.php

index 13efb81..8c06ef4 100644 (file)
@@ -3417,6 +3417,11 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        $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;
@@ -3475,6 +3480,11 @@ 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 ) {
@@ -3525,6 +3535,11 @@ 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