X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/deferred/AtomicSectionUpdate.php diff --git a/includes/deferred/AtomicSectionUpdate.php b/includes/deferred/AtomicSectionUpdate.php new file mode 100644 index 00000000..8b62989b --- /dev/null +++ b/includes/deferred/AtomicSectionUpdate.php @@ -0,0 +1,48 @@ +dbw = $dbw; + $this->fname = $fname; + $this->callback = $callback; + + if ( $this->dbw->trxLevel() ) { + $this->dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname ); + } + } + + public function doUpdate() { + if ( $this->callback ) { + $this->dbw->doAtomicSection( $this->fname, $this->callback ); + } + } + + public function cancelOnRollback( $trigger ) { + if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) { + $this->callback = null; + } + } + + public function getOrigin() { + return $this->fname; + } +}