X-Git-Url: http://git.cyclocoop.org/%28?a=blobdiff_plain;f=includes%2Fdeferred%2FAtomicSectionUpdate.php;h=69f09e392868f7726ae260c8c1fa018748c24867;hb=f0c24143231d90ff409ddee62c853e8b6e1522bb;hp=8b62989b53ab284c06e94e9e1b58fb6d2363bf62;hpb=9b4fd6a6c054a8b012ea0d358478f3ee1c392469;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/deferred/AtomicSectionUpdate.php b/includes/deferred/AtomicSectionUpdate.php index 8b62989b53..69f09e3928 100644 --- a/includes/deferred/AtomicSectionUpdate.php +++ b/includes/deferred/AtomicSectionUpdate.php @@ -15,18 +15,22 @@ class AtomicSectionUpdate implements DeferrableUpdate, DeferrableCallback { private $callback; /** - * @param IDatabase $dbw + * @param IDatabase $dbw DB handle; update aborts if a transaction now this rolls back * @param string $fname Caller name (usually __METHOD__) * @param callable $callback + * @param IDatabase[] $conns Abort if a transaction now on one of these rolls back [optional] * @see IDatabase::doAtomicSection() */ - public function __construct( IDatabase $dbw, $fname, callable $callback ) { + public function __construct( IDatabase $dbw, $fname, callable $callback, array $conns = [] ) { $this->dbw = $dbw; $this->fname = $fname; $this->callback = $callback; - - if ( $this->dbw->trxLevel() ) { - $this->dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname ); + // Register DB connections for which uncommitted changes are related to this update + $conns[] = $dbw; + foreach ( $conns as $conn ) { + if ( $conn->trxLevel() ) { + $conn->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname ); + } } } @@ -36,6 +40,10 @@ class AtomicSectionUpdate implements DeferrableUpdate, DeferrableCallback { } } + /** + * @private This method is public so that it works with onTransactionResolution() + * @param int $trigger + */ public function cancelOnRollback( $trigger ) { if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) { $this->callback = null;