From 3f495e45193014a7a84234a3f50b439488fa95ea Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 16 May 2014 10:50:05 -0700 Subject: [PATCH] Avoid fatals in begin/commit/rollback if close() was called Change-Id: I3c555ece5c1e16c6ffcdbec6645d659531400a1b --- includes/db/Database.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/db/Database.php b/includes/db/Database.php index 286f8b0b96..5212d3c855 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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 -- 2.20.1