MediaWiki REL1_35
AtomicSectionUpdate.php
Go to the documentation of this file.
1<?php
2
4
11 private $dbw;
13 private $fname;
15 private $callback;
16
24 public function __construct( IDatabase $dbw, $fname, callable $callback, array $conns = [] ) {
25 $this->dbw = $dbw;
26 $this->fname = $fname;
27 $this->callback = $callback;
28 // Register DB connections for which uncommitted changes are related to this update
29 $conns[] = $dbw;
30 foreach ( $conns as $conn ) {
31 if ( $conn->trxLevel() ) {
32 $conn->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
33 }
34 }
35 }
36
37 public function doUpdate() {
38 if ( $this->callback ) {
39 $this->dbw->doAtomicSection( $this->fname, $this->callback );
40 }
41 }
42
47 public function cancelOnRollback( $trigger ) {
48 if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) {
49 $this->callback = null;
50 }
51 }
52
53 public function getOrigin() {
54 return $this->fname;
55 }
56}
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
__construct(IDatabase $dbw, $fname, callable $callback, array $conns=[])
doUpdate()
Perform the actual work.
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
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback as soon as the current transaction commits or rolls back.