From ccab8f10f67e4d733a12118c5c18e5afa7af451c Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 7 Oct 2015 23:46:18 -0700 Subject: [PATCH] Make DeferredUpdates::doUpdates use DataUpdate::runUpdates All DataUpdate objects will be managed by runUpdates() while the other DeferrableUpdate objects will still be run here. This respects the transaction sematics of DataUpdate a bit more. Change-Id: Ia0d2dd26a38b0e8911589407b533b58d04d2b084 --- includes/deferred/DeferredUpdates.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php index 7d02a7a9cf..8b3582db69 100644 --- a/includes/deferred/DeferredUpdates.php +++ b/includes/deferred/DeferredUpdates.php @@ -44,7 +44,7 @@ interface DeferrableUpdate { * @since 1.19 */ class DeferredUpdates { - /** @var array Updates to be deferred until the end of the request */ + /** @var DeferrableUpdate[] Updates to be deferred until the end of the request */ private static $updates = array(); /** @var bool Defer updates fully even in CLI mode */ private static $forceDeferral = false; @@ -102,9 +102,22 @@ class DeferredUpdates { while ( count( $updates ) ) { self::clearPendingUpdates(); - - /** @var DeferrableUpdate $update */ + /** @var DataUpdate[] $dataUpdates */ + $dataUpdates = array(); + /** @var DeferrableUpdate[] $otherUpdates */ + $otherUpdates = array(); foreach ( $updates as $update ) { + if ( $update instanceof DataUpdate ) { + $dataUpdates[] = $update; + } else { + $otherUpdates[] = $update; + } + } + + // Delegate DataUpdate execution to the DataUpdate class + DataUpdate::runUpdates( $dataUpdates, 'run' ); + // Execute the non-DataUpdate tasks + foreach ( $otherUpdates as $update ) { try { $update->doUpdate(); -- 2.20.1