*
* @file
*/
+use Wikimedia\Rdbms\IDatabase;
use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\LBFactory;
+use Wikimedia\Rdbms\LoadBalancer;
/**
* Class for managing the deferred updates
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
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 ) {
/**
* @param bool $value Whether to just immediately run updates in addUpdate()
* @since 1.28
+ * @deprecated 1.29 Causes issues in Web-executed jobs - see T165714 and T100085.
*/
public static function setImmediateMode( $value ) {
- self::$immediateMode = (bool)$value;
+ wfDeprecated( __METHOD__, '1.29' );
}
/**
return count( self::$preSendUpdates ) + count( self::$postSendUpdates );
}
+ /**
+ * @param integer $stage DeferredUpdates constant (PRESEND, POSTSEND, or ALL)
+ * @since 1.29
+ */
+ public static function getPendingUpdates( $stage = self::ALL ) {
+ $updates = [];
+ if ( $stage === self::ALL || $stage === self::PRESEND ) {
+ $updates = array_merge( $updates, self::$preSendUpdates );
+ }
+ if ( $stage === self::ALL || $stage === self::POSTSEND ) {
+ $updates = array_merge( $updates, self::$postSendUpdates );
+ }
+ return $updates;
+ }
+
/**
* Clear all pending updates without performing them. Generally, you don't
* want or need to call this. Unit tests need it though.