Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/84880
Change subject: Allow for cancellation of deferred updates ...................................................................... Allow for cancellation of deferred updates Change-Id: I9ef88a3230028e2675b4c671d20e343f4d7e7a2b --- M includes/DeferredUpdates.php 1 file changed, 24 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/80/84880/1 diff --git a/includes/DeferredUpdates.php b/includes/DeferredUpdates.php index a321414..d62fc24 100644 --- a/includes/DeferredUpdates.php +++ b/includes/DeferredUpdates.php @@ -39,17 +39,19 @@ * @since 1.19 */ class DeferredUpdates { - /** - * Store of updates to be deferred until the end of the request. - */ + /** @var Array updates to be deferred until the end of the request */ private static $updates = array(); + /** @var integer Unique ID counter */ + private static $counter = 0; /** * Add an update to the deferred list * @param $update DeferrableUpdate Some object that implements doUpdate() + * @returns integer Update receipt */ public static function addUpdate( DeferrableUpdate $update ) { - array_push( self::$updates, $update ); + self::$updates[++self::$counter] = self::$updates; + return self::$counter; } /** @@ -58,9 +60,10 @@ * @see HTMLCacheUpdate::__construct() * @param $title * @param $table + * @returns integer Update receipt */ public static function addHTMLCacheUpdate( $title, $table ) { - self::addUpdate( new HTMLCacheUpdate( $title, $table ) ); + return self::addUpdate( new HTMLCacheUpdate( $title, $table ) ); } /** @@ -68,9 +71,24 @@ * defining a new DeferrableUpdate object is not necessary * @see MWCallableUpdate::__construct() * @param callable $callable + * @returns integer Update receipt */ public static function addCallableUpdate( $callable ) { - self::addUpdate( new MWCallableUpdate( $callable ) ); + return self::addUpdate( new MWCallableUpdate( $callable ) ); + } + + /** + * Cancel a pending deferred update + * @param integer $id Update receipt + * @return bool Whether an update was found + */ + public static function cancelUpdate( $id ) { + if ( isset( self::$updates[$id] ) ) { + unset( self::$updates[$id] ); + return true; + } else { + return false; + } } /** -- To view, visit https://gerrit.wikimedia.org/r/84880 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9ef88a3230028e2675b4c671d20e343f4d7e7a2b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits