MediaWiki REL1_31
AtomicSectionUpdate.php
Go to the documentation of this file.
1<?php
2
4
11 private $dbw;
13 private $fname;
15 private $callback;
16
23 public function __construct( IDatabase $dbw, $fname, callable $callback ) {
24 $this->dbw = $dbw;
25 $this->fname = $fname;
26 $this->callback = $callback;
27
28 if ( $this->dbw->trxLevel() ) {
29 $this->dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
30 }
31 }
32
33 public function doUpdate() {
34 if ( $this->callback ) {
35 $this->dbw->doAtomicSection( $this->fname, $this->callback );
36 }
37 }
38
39 public function cancelOnRollback( $trigger ) {
40 if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) {
41 $this->callback = null;
42 }
43 }
44
45 public function getOrigin() {
46 return $this->fname;
47 }
48}
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
doUpdate()
Perform the actual work.
__construct(IDatabase $dbw, $fname, callable $callback)
Callback wrapper that has an originating method.
Interface that deferrable updates should implement.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38