MediaWiki REL1_30
MWCallableUpdate.php
Go to the documentation of this file.
1<?php
2
4
10 private $callback;
12 private $fname;
13
19 public function __construct( callable $callback, $fname = 'unknown', IDatabase $dbw = null ) {
20 $this->callback = $callback;
21 $this->fname = $fname;
22
23 if ( $dbw && $dbw->trxLevel() ) {
24 $dbw->onTransactionResolution( [ $this, 'cancelOnRollback' ], $fname );
25 }
26 }
27
28 public function doUpdate() {
29 if ( $this->callback ) {
30 call_user_func( $this->callback );
31 }
32 }
33
34 public function cancelOnRollback( $trigger ) {
35 if ( $trigger === IDatabase::TRIGGER_ROLLBACK ) {
36 $this->callback = null;
37 }
38 }
39
40 public function getOrigin() {
41 return $this->fname;
42 }
43}
Deferrable Update for closure/callback.
cancelOnRollback( $trigger)
callable null $callback
doUpdate()
Perform the actual work.
__construct(callable $callback, $fname='unknown', IDatabase $dbw=null)
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:40