4 * Deferrable Update for closure/callback
6 class MWCallableUpdate
implements DeferrableUpdate
, DeferrableCallback
{
7 /** @var callable|null */
13 * @param callable $callback
14 * @param string $fname Calling method
15 * @param IDatabase|null $dbw Abort if this DB is rolled back [optional] (since 1.28)
17 public function __construct( callable
$callback, $fname = 'unknown', IDatabase
$dbw = null ) {
18 $this->callback
= $callback;
19 $this->fname
= $fname;
21 if ( $dbw && $dbw->trxLevel() ) {
22 $dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
26 public function doUpdate() {
27 if ( $this->callback
) {
28 call_user_func( $this->callback
);
32 public function cancelOnRollback( $trigger ) {
33 if ( $trigger === IDatabase
::TRIGGER_ROLLBACK
) {
34 $this->callback
= null;
38 public function getOrigin() {