dbw = $dbw; $this->fname = $fname; $this->callback = $callback; // 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 ); } } } public function doUpdate() { if ( !$this->callback ) { return; } $autoTrx = $this->dbw->getFlag( DBO_TRX ); $this->dbw->clearFlag( DBO_TRX ); try { ( $this->callback )( $this->dbw, $this->fname ); } finally { if ( $autoTrx ) { $this->dbw->setFlag( DBO_TRX ); } } } /** * @internal 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; } } public function getOrigin() { return $this->fname; } } /** @deprecated class alias since 1.42 */ class_alias( AutoCommitUpdate::class, 'AutoCommitUpdate' );