From: Aaron Schulz Date: Fri, 22 Jul 2016 23:56:10 +0000 (-0700) Subject: Minor transaction callback cleanups X-Git-Tag: 1.31.0-rc.0~6283 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=fe5a3fe03d19b1aca6ef113307539279e09717e5;p=lhc%2Fweb%2Fwiklou.git Minor transaction callback cleanups * Give the flush commit() in close() a chance to handle callbacks. Also detect onTransactionResolution() callbacks when an error is thrown. * Avoid resetting callbacks redundantly, as they already get cleared when they actually run. * Fix a few doc comments. Change-Id: I5c62262661b97a6c28ce0ab0949307dc119953ca --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 9b73584cd9..bda4ccf507 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -694,9 +694,6 @@ abstract class DatabaseBase implements IDatabase { } public function close() { - if ( count( $this->mTrxIdleCallbacks ) ) { // sanity - throw new MWException( "Transaction idle callbacks still pending." ); - } if ( $this->mConn ) { if ( $this->trxLevel() ) { if ( !$this->mTrxAutomatic ) { @@ -709,6 +706,8 @@ abstract class DatabaseBase implements IDatabase { $closed = $this->closeConnection(); $this->mConn = false; + } elseif ( $this->mTrxIdleCallbacks || $this->mTrxEndCallbacks ) { // sanity + throw new MWException( "Transaction callbacks still pending." ); } else { $closed = true; } @@ -2473,7 +2472,7 @@ abstract class DatabaseBase implements IDatabase { } /** - * Actually any "on transaction idle" callbacks. + * Actually run and consume any "on transaction idle" callbacks. * * @param integer $trigger IDatabase::TRIGGER_* constant * @since 1.20 @@ -2519,7 +2518,7 @@ abstract class DatabaseBase implements IDatabase { } /** - * Actually any "on transaction pre-commit" callbacks. + * Actually run and consume any "on transaction pre-commit" callbacks. * * This method should not be used outside of Database/LoadBalancer * @@ -2637,8 +2636,6 @@ abstract class DatabaseBase implements IDatabase { $this->mTrxAutomatic = false; $this->mTrxAutomaticAtomic = false; $this->mTrxAtomicLevels = []; - $this->mTrxIdleCallbacks = []; - $this->mTrxPreCommitCallbacks = []; $this->mTrxShortId = wfRandomString( 12 ); $this->mTrxWriteDuration = 0.0; $this->mTrxWriteCallers = [];