MediaWiki REL1_32
MWCallableUpdate.php
Go to the documentation of this file.
1<?php
2
4
10 private $callback;
12 private $fname;
13
20 public function __construct( callable $callback, $fname = 'unknown', $dbws = [] ) {
21 $this->callback = $callback;
22 $this->fname = $fname;
23
24 $dbws = is_array( $dbws ) ? $dbws : [ $dbws ];
25 foreach ( $dbws as $dbw ) {
26 if ( $dbw && $dbw->trxLevel() ) {
27 $dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
28 }
29 }
30 }
31
32 public function doUpdate() {
33 if ( $this->callback ) {
34 call_user_func( $this->callback );
35 }
36 }
37
38 public function cancelOnRollback( $trigger ) {
39 if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) {
40 $this->callback = null;
41 }
42 }
43
44 public function getOrigin() {
45 return $this->fname;
46 }
47}
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition Setup.php:121
Deferrable Update for closure/callback.
cancelOnRollback( $trigger)
callable null $callback
doUpdate()
Perform the actual work.
__construct(callable $callback, $fname='unknown', $dbws=[])
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