callback = $callback; $this->fname = $fname; $dependeeDbws = is_array( $dependeeDbws ) ? $dependeeDbws : [ $dependeeDbws ]; foreach ( $dependeeDbws as $dbw ) { if ( $dbw->trxLevel() ) { $dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname ); } } } public function doUpdate() { if ( $this->callback instanceof Closure ) { ( $this->callback )( $this->fname ); } elseif ( $this->callback ) { // For backwards-compatibility with [$classOrObject, 'func'] style callbacks // where the function happened to already take an optional parameter. ( $this->callback )(); } } /** * @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; } /** * @param int $mode One of the class TRX_ROUND_* constants */ public function setTransactionRoundRequirement( $mode ) { $this->trxRoundRequirement = $mode; } public function getTransactionRoundRequirement() { return $this->trxRoundRequirement; } } /** @deprecated class alias since 1.42 */ class_alias( MWCallableUpdate::class, 'MWCallableUpdate' );