X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdeferred%2FAutoCommitUpdate.php;h=ddfd98716d8da8814f046813b541ed88a4d07e5e;hb=e65f8ac5110804067366f9f239c13f4f29b66c3d;hp=85071576b07834681ed72eab0cf7e7f16bdca235;hpb=2dd32981a8326a6207ac866b39410f1b86179288;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/deferred/AutoCommitUpdate.php b/includes/deferred/AutoCommitUpdate.php index 85071576b0..ddfd98716d 100644 --- a/includes/deferred/AutoCommitUpdate.php +++ b/includes/deferred/AutoCommitUpdate.php @@ -15,17 +15,21 @@ class AutoCommitUpdate 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 Callback that takes (IDatabase, method name string) + * @param IDatabase[] $conns Abort if a transaction now on one of these rolls back [optional] */ - 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 ); + } } } @@ -50,6 +54,10 @@ class AutoCommitUpdate 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;