MediaWiki
1.34.0
AtomicSectionUpdate.php
Go to the documentation of this file.
1
<?php
2
3
use
Wikimedia\Rdbms\IDatabase
;
4
9
class
AtomicSectionUpdate
implements
DeferrableUpdate
,
DeferrableCallback
{
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
}
DeferrableCallback
Callback wrapper that has an originating method.
Definition:
DeferrableCallback.php:8
AtomicSectionUpdate\__construct
__construct(IDatabase $dbw, $fname, callable $callback, array $conns=[])
Definition:
AtomicSectionUpdate.php:24
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition:
IDatabase.php:38
AtomicSectionUpdate\cancelOnRollback
cancelOnRollback( $trigger)
Definition:
AtomicSectionUpdate.php:47
AtomicSectionUpdate\doUpdate
doUpdate()
Perform the actual work.
Definition:
AtomicSectionUpdate.php:37
AtomicSectionUpdate
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
Definition:
AtomicSectionUpdate.php:9
AtomicSectionUpdate\getOrigin
getOrigin()
Definition:
AtomicSectionUpdate.php:53
AtomicSectionUpdate\$fname
string $fname
Definition:
AtomicSectionUpdate.php:13
AtomicSectionUpdate\$dbw
IDatabase $dbw
Definition:
AtomicSectionUpdate.php:11
AtomicSectionUpdate\$callback
callable null $callback
Definition:
AtomicSectionUpdate.php:15
DeferrableUpdate
Interface that deferrable updates should implement.
Definition:
DeferrableUpdate.php:9
Wikimedia\Rdbms\IDatabase\onTransactionResolution
onTransactionResolution(callable $callback, $fname=__METHOD__)
Run a callback as soon as the current transaction commits or rolls back.
includes
deferred
AtomicSectionUpdate.php
Generated on Thu Dec 19 2019 14:54:14 for MediaWiki by
1.8.16