MediaWiki master
MWCallableUpdate.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Deferred;
4
6
14{
16 private $callback;
18 private $fname;
20 private $trxRoundRequirement = self::TRX_ROUND_PRESENT;
21
28 public function __construct( callable $callback, $fname = 'unknown', $dbws = [] ) {
29 $this->callback = $callback;
30 $this->fname = $fname;
31
32 $dbws = is_array( $dbws ) ? $dbws : [ $dbws ];
33 foreach ( $dbws as $dbw ) {
34 if ( $dbw && $dbw->trxLevel() ) {
35 $dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
36 }
37 }
38 }
39
40 public function doUpdate() {
41 if ( $this->callback ) {
42 call_user_func( $this->callback );
43 }
44 }
45
50 public function cancelOnRollback( $trigger ) {
51 if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) {
52 $this->callback = null;
53 }
54 }
55
56 public function getOrigin() {
57 return $this->fname;
58 }
59
64 public function setTransactionRoundRequirement( $mode ) {
65 $this->trxRoundRequirement = $mode;
66 }
67
69 return $this->trxRoundRequirement;
70 }
71}
72
74class_alias( MWCallableUpdate::class, 'MWCallableUpdate' );
DeferrableUpdate for closure/callable.
__construct(callable $callback, $fname='unknown', $dbws=[])
doUpdate()
Perform the actual work.
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:36