MediaWiki REL1_35
MWCallableUpdate.php
Go to the documentation of this file.
1<?php
2
4
10{
12 private $callback;
14 private $fname;
16 private $trxRoundRequirement = self::TRX_ROUND_PRESENT;
17
24 public function __construct( callable $callback, $fname = 'unknown', $dbws = [] ) {
25 $this->callback = $callback;
26 $this->fname = $fname;
27
28 $dbws = is_array( $dbws ) ? $dbws : [ $dbws ];
29 foreach ( $dbws as $dbw ) {
30 if ( $dbw && $dbw->trxLevel() ) {
31 $dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
32 }
33 }
34 }
35
36 public function doUpdate() {
37 if ( $this->callback ) {
38 call_user_func( $this->callback );
39 }
40 }
41
46 public function cancelOnRollback( $trigger ) {
47 if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) {
48 $this->callback = null;
49 }
50 }
51
52 public function getOrigin() {
53 return $this->fname;
54 }
55
60 public function setTransactionRoundRequirement( $mode ) {
61 $this->trxRoundRequirement = $mode;
62 }
63
67}
Deferrable Update for closure/callback.
string $fname
Calling method name.
cancelOnRollback( $trigger)
callable null $callback
Callback, or null if it was cancelled.
int $trxRoundRequirement
One of the class TRX_ROUND_* constants.
doUpdate()
Perform the actual work.
setTransactionRoundRequirement( $mode)
__construct(callable $callback, $fname='unknown', $dbws=[])
Callback wrapper that has an originating method.
Interface that deferrable updates should implement.
Deferrable update that specifies whether it must run outside of any explicit LBFactory transaction ro...
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38