Merge "Add a message to localize strings like "2×" and use it in enhanced RC"
[lhc/web/wiklou.git] / includes / deferred / DeferredUpdates.php
index 51f5a28..a3a37f6 100644 (file)
@@ -286,7 +286,7 @@ class DeferredUpdates {
                }
 
                // Avoiding running updates without them having outer scope
-               if ( !self::getBusyDbConnections() ) {
+               if ( !self::areDatabaseTransactionsActive() ) {
                        self::doUpdates( $mode );
                        return true;
                }
@@ -356,16 +356,19 @@ class DeferredUpdates {
        }
 
        /**
-        * @return IDatabase[] Connection where commit() cannot be called yet
+        * @return bool If a transaction round is active or connection is not ready for commit()
         */
-       private static function getBusyDbConnections() {
-               $connsBusy = [];
-
+       private static function areDatabaseTransactionsActive() {
                $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+               if ( $lbFactory->hasTransactionRound() ) {
+                       return true;
+               }
+
+               $connsBusy = false;
                $lbFactory->forEachLB( function ( LoadBalancer $lb ) use ( &$connsBusy ) {
                        $lb->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( &$connsBusy ) {
                                if ( $conn->writesOrCallbacksPending() || $conn->explicitTrxActive() ) {
-                                       $connsBusy[] = $conn;
+                                       $connsBusy = true;
                                }
                        } );
                } );