jenkins-bot has submitted this change and it was merged.

Change subject: Minor transaction callback cleanups
......................................................................


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
---
M includes/db/Database.php
1 file changed, 4 insertions(+), 7 deletions(-)

Approvals:
  Reedy: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/Database.php b/includes/db/Database.php
index 9b73584..bda4ccf 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -694,9 +694,6 @@
        }
 
        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 @@
 
                        $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 @@
        }
 
        /**
-        * 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 @@
        }
 
        /**
-        * 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 @@
                $this->mTrxAutomatic = false;
                $this->mTrxAutomaticAtomic = false;
                $this->mTrxAtomicLevels = [];
-               $this->mTrxIdleCallbacks = [];
-               $this->mTrxPreCommitCallbacks = [];
                $this->mTrxShortId = wfRandomString( 12 );
                $this->mTrxWriteDuration = 0.0;
                $this->mTrxWriteCallers = [];

-- 
To view, visit https://gerrit.wikimedia.org/r/300684
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5c62262661b97a6c28ce0ab0949307dc119953ca
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to