MediaWiki  1.34.0
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 
64  public function getTransactionRoundRequirement() {
66  }
67 }
MWCallableUpdate\$fname
string $fname
Calling method name.
Definition: MWCallableUpdate.php:14
MWCallableUpdate\$callback
callable null $callback
Callback, or null if it was cancelled.
Definition: MWCallableUpdate.php:12
DeferrableCallback
Callback wrapper that has an originating method.
Definition: DeferrableCallback.php:8
TransactionRoundAwareUpdate
Deferrable update that specifies whether it must run outside of any explicit LBFactory transaction ro...
Definition: TransactionRoundAwareUpdate.php:9
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
MWCallableUpdate\cancelOnRollback
cancelOnRollback( $trigger)
Definition: MWCallableUpdate.php:46
MWCallableUpdate\getTransactionRoundRequirement
getTransactionRoundRequirement()
Definition: MWCallableUpdate.php:64
MWCallableUpdate\doUpdate
doUpdate()
Perform the actual work.
Definition: MWCallableUpdate.php:36
MWCallableUpdate\$trxRoundRequirement
int $trxRoundRequirement
One of the class TRX_ROUND_* constants.
Definition: MWCallableUpdate.php:16
MWCallableUpdate\getOrigin
getOrigin()
Definition: MWCallableUpdate.php:52
MWCallableUpdate\setTransactionRoundRequirement
setTransactionRoundRequirement( $mode)
Definition: MWCallableUpdate.php:60
MWCallableUpdate
Deferrable Update for closure/callback.
Definition: MWCallableUpdate.php:8
DeferrableUpdate
Interface that deferrable updates should implement.
Definition: DeferrableUpdate.php:9
MWCallableUpdate\__construct
__construct(callable $callback, $fname='unknown', $dbws=[])
Definition: MWCallableUpdate.php:24