2017-10-12 20:19:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
2023-11-21 21:08:14 +00:00
|
|
|
namespace MediaWiki\Deferred;
|
|
|
|
|
|
2024-02-09 17:46:37 +00:00
|
|
|
use Wikimedia\Rdbms\Platform\ISQLPlatform;
|
|
|
|
|
|
2017-10-12 20:19:56 +00:00
|
|
|
/**
|
2018-04-16 20:38:01 +00:00
|
|
|
* Deferrable update that must run outside of any explicit LBFactory transaction round
|
2017-10-12 20:19:56 +00:00
|
|
|
*
|
|
|
|
|
* @since 1.31
|
|
|
|
|
*/
|
2019-05-21 21:52:57 +00:00
|
|
|
class TransactionRoundDefiningUpdate
|
|
|
|
|
implements DeferrableUpdate, DeferrableCallback, TransactionRoundAwareUpdate
|
|
|
|
|
{
|
2017-10-12 20:19:56 +00:00
|
|
|
/** @var callable|null */
|
|
|
|
|
private $callback;
|
|
|
|
|
/** @var string */
|
|
|
|
|
private $fname;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param callable $callback
|
2024-10-11 18:46:13 +00:00
|
|
|
* @param string $fname Calling method @phan-mandatory-param
|
2017-10-12 20:19:56 +00:00
|
|
|
*/
|
2024-02-09 17:46:37 +00:00
|
|
|
public function __construct( callable $callback, $fname = ISQLPlatform::CALLER_UNKNOWN ) {
|
2017-10-12 20:19:56 +00:00
|
|
|
$this->callback = $callback;
|
|
|
|
|
$this->fname = $fname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function doUpdate() {
|
|
|
|
|
call_user_func( $this->callback );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getOrigin() {
|
|
|
|
|
return $this->fname;
|
|
|
|
|
}
|
2019-05-21 21:52:57 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return int One of the class TRX_ROUND_* constants
|
|
|
|
|
* @since 1.34
|
|
|
|
|
*/
|
|
|
|
|
final public function getTransactionRoundRequirement() {
|
|
|
|
|
return self::TRX_ROUND_ABSENT;
|
|
|
|
|
}
|
2017-10-12 20:19:56 +00:00
|
|
|
}
|
2023-11-21 21:08:14 +00:00
|
|
|
|
2024-03-07 21:56:58 +00:00
|
|
|
/** @deprecated class alias since 1.42 */
|
2023-11-21 21:08:14 +00:00
|
|
|
class_alias( TransactionRoundDefiningUpdate::class, 'TransactionRoundDefiningUpdate' );
|