wiki.techinc.nl/includes/deferred/TransactionRoundDefiningUpdate.php
Aaron Schulz ef949d79d2 Introduce TransactionRoundAwareUpdate interface
Refactor the deferred update transaction round handling code to use
a new TransactionRoundAwareUpdate interface. Also, rename a few
DeferredUpdates methods so they do not give the impression that
doUpdates() is always called.

Change-Id: Idc4c6d81c4e2ca0ce41bca1e7800f797fa7e37f6
2019-05-25 02:33:05 +00:00

40 lines
841 B
PHP

<?php
/**
* Deferrable update that must run outside of any explicit LBFactory transaction round
*
* @since 1.31
*/
class TransactionRoundDefiningUpdate
implements DeferrableUpdate, DeferrableCallback, TransactionRoundAwareUpdate
{
/** @var callable|null */
private $callback;
/** @var string */
private $fname;
/**
* @param callable $callback
* @param string $fname Calling method
*/
public function __construct( callable $callback, $fname = 'unknown' ) {
$this->callback = $callback;
$this->fname = $fname;
}
public function doUpdate() {
call_user_func( $this->callback );
}
public function getOrigin() {
return $this->fname;
}
/**
* @return int One of the class TRX_ROUND_* constants
* @since 1.34
*/
final public function getTransactionRoundRequirement() {
return self::TRX_ROUND_ABSENT;
}
}