4 * Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
7 class AtomicSectionUpdate
implements DeferrableUpdate
, DeferrableCallback
{
12 /** @var callable|null */
16 * @param IDatabase $dbw
17 * @param string $fname Caller name (usually __METHOD__)
18 * @param callable $callback
19 * @see IDatabase::doAtomicSection()
21 public function __construct( IDatabase
$dbw, $fname, callable
$callback ) {
23 $this->fname
= $fname;
24 $this->callback
= $callback;
26 if ( $this->dbw
->trxLevel() ) {
27 $this->dbw
->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
31 public function doUpdate() {
32 if ( $this->callback
) {
33 $this->dbw
->doAtomicSection( $this->fname
, $this->callback
);
37 public function cancelOnRollback( $trigger ) {
38 if ( $trigger === IDatabase
::TRIGGER_ROLLBACK
) {
39 $this->callback
= null;
43 public function getOrigin() {