X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fdeferred%2FDeferredUpdates.php;h=1ba6c1febdfef9bb7032c17b48bbf8acce8b1d95;hb=61898ad28ed69c5b391eb43e0db9386279b9612c;hp=d24ebde7d6c7404e3a9b5c41ab3023a981ffc68a;hpb=65d7d79d1ba09afc362f9e542b7df97b7ecc9c3e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php index d24ebde7d6..1ba6c1febd 100644 --- a/includes/deferred/DeferredUpdates.php +++ b/includes/deferred/DeferredUpdates.php @@ -52,6 +52,8 @@ class DeferredUpdates { private static $preSendUpdates = []; /** @var DeferrableUpdate[] Updates to be deferred until after request end */ private static $postSendUpdates = []; + /** @var bool Whether to just run updates in addUpdate() */ + private static $immediateMode = false; const ALL = 0; // all updates; in web requests, use only after flushing the output buffer const PRESEND = 1; // for updates that should run before flushing output buffer @@ -85,6 +87,12 @@ class DeferredUpdates { self::push( self::$postSendUpdates, $update ); } + if ( self::$immediateMode ) { + // No more explicit doUpdates() calls will happen, so run this now + self::doUpdates( 'run' ); + return; + } + // Try to run the updates now if in CLI mode and no transaction is active. // This covers scripts that don't/barely use the DB but make updates to other stores. if ( $wgCommandLineMode ) { @@ -126,6 +134,14 @@ class DeferredUpdates { } } + /** + * @param bool $value Whether to just immediately run updates in addUpdate() + * @since 1.28 + */ + public static function setImmediateMode( $value ) { + self::$immediateMode = (bool)$value; + } + /** * @param DeferrableUpdate[] $queue * @param DeferrableUpdate $update @@ -214,6 +230,10 @@ class DeferredUpdates { $firstKey = key( self::$executeContext['subqueue'] ); unset( self::$executeContext['subqueue'][$firstKey] ); + if ( $subUpdate instanceof DataUpdate ) { + $subUpdate->setTransactionTicket( $ticket ); + } + $guiError = self::runUpdate( $subUpdate, $lbFactory, $stage ); $reportableError = $reportableError ?: $guiError; }