getDeferredUpdatesManager() ->addUpdate( $update, $stage ); } /** * Add an update to the pending update queue that invokes the specified callback when run * * @see DeferredUpdates::addUpdate() * @see MWCallableUpdate::__construct() * * @param callable $callable * @param int $stage One of (DeferredUpdates::PRESEND, DeferredUpdates::POSTSEND) * @param IDatabase|IDatabase[]|null $dbw Abort if this DB is rolled back [optional] * @since 1.27 Added $stage parameter * @since 1.28 Added the $dbw parameter */ public static function addCallableUpdate( $callable, $stage = self::POSTSEND, $dbw = null ) { // Migrating to DeferredUpdatesManager service. Cannot just call the corresponding // DeferredUpdatesManager::addCallableUpdate() because that would have a different // result for wfGetCaller(), so we duplicate the logic for creating the MWCallableUpdate MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->addUpdate( new MWCallableUpdate( $callable, wfGetCaller(), $dbw ), $stage ); } /** * Consume and execute all pending updates * * Note that it is rarely the case that this method should be called outside of a few * select entry points. For simplicity, that kind of recursion is discouraged. Recursion * cannot happen if an explicit transaction round is active, which limits usage to updates * with TRX_ROUND_ABSENT that do not leave open any transactions round of their own during * the call to this method. * * In the less-common case of this being called within an in-progress DeferrableUpdate, * this will not see any top-queue updates (since they were consumed and are being run * inside an outer execution loop). In that case, it will instead operate on the sub-queue * of the innermost in-progress update on the stack. * * @internal For use by MediaWiki, Maintenance, JobRunner, JobExecutor * @param int $stage Which updates to process. One of * (DeferredUpdates::PRESEND, DeferredUpdates::POSTSEND, DeferredUpdates::ALL) */ public static function doUpdates( $stage = self::ALL ) { // Migrating to DeferredUpdatesManager service MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->doUpdates( $stage ); } /** * Consume and execute all pending updates unless an update is already * in progress or the ILBFactory service instance has "busy" DB handles * * A DB handle is considered "busy" if it has an unfinished transaction that cannot safely * be flushed or the parent ILBFactory instance has an unfinished transaction round that * cannot safely be flushed. If the number of pending updates reaches BIG_QUEUE_SIZE and * there are still busy DB handles, then EnqueueableDataUpdate updates might be enqueued * as jobs. This avoids excessive memory use and risk of losing updates due to failures. * * Note that this method operates on updates from all stages and thus should not be called * during web requests. It is only intended for long-running Maintenance scripts. * * @internal For use by Maintenance * @since 1.28 * @return bool Whether updates were allowed to run */ public static function tryOpportunisticExecute(): bool { // Migrating to DeferredUpdatesManager service return MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->tryOpportunisticExecute(); } /** * Prevent opportunistic updates until the returned ScopedCallback is * consumed. * * @return ScopedCallback */ public static function preventOpportunisticUpdates() { // Migrating to DeferredUpdatesManager service return MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->preventOpportunisticUpdates(); } /** * Get the number of pending updates for the current execution context * * If an update is in progress, then this operates on the sub-queues of the * innermost in-progress update. Otherwise, it acts on the top-queues. * * @return int * @since 1.28 */ public static function pendingUpdatesCount() { // Migrating to DeferredUpdatesManager service return MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->pendingUpdatesCount(); } /** * Get a list of the pending updates for the current execution context * * If an update is in progress, then this operates on the sub-queues of the * innermost in-progress update. Otherwise, it acts on the top-queues. * * @param int $stage Look for updates with this "defer until" stage. One of * (DeferredUpdates::PRESEND, DeferredUpdates::POSTSEND, DeferredUpdates::ALL) * @return DeferrableUpdate[] * @internal This method should only be used for unit tests * @since 1.29 */ public static function getPendingUpdates( $stage = self::ALL ) { // Migrating to DeferredUpdatesManager service return MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->getPendingUpdates( $stage ); } /** * Cancel all pending updates for the current execution context * * If an update is in progress, then this operates on the sub-queues of the * innermost in-progress update. Otherwise, it acts on the top-queues. * * @internal This method should only be used for unit tests */ public static function clearPendingUpdates() { // Migrating to DeferredUpdatesManager service MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->clearPendingUpdates(); } /** * Get the number of in-progress calls to DeferredUpdates::doUpdates() * * @return int * @internal This method should only be used for unit tests */ public static function getRecursiveExecutionStackDepth() { // Migrating to DeferredUpdatesManager service return MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->getRecursiveExecutionStackDepth(); } /** * Attempt to run an update with the appropriate transaction round state it expects * * DeferredUpdate classes that wrap the execution of bundles of other DeferredUpdate * instances can use this method to run the updates. Any such wrapper class should * always use TRX_ROUND_ABSENT itself. * * @param DeferrableUpdate $update * @param ILBFactory $lbFactory * @since 1.34 */ public static function attemptUpdate( DeferrableUpdate $update, ILBFactory $lbFactory ) { // Migrating to DeferredUpdatesManager service MediaWikiServices::getInstance() ->getDeferredUpdatesManager() ->attemptUpdate( $update, $lbFactory ); } }