Make DeferredUpdates enqueue updates that failed to run when possible
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 12 Oct 2018 20:49:25 +0000 (13:49 -0700)
committerKrinkle <krinklemail@gmail.com>
Fri, 15 Mar 2019 19:14:07 +0000 (19:14 +0000)
Bug: T206288
Bug: T206283
Change-Id: I6025bcc7d68cf214d291191d4044a66cdeff108b

includes/deferred/DeferredUpdates.php

index 67b5490..a14b25c 100644 (file)
@@ -280,6 +280,16 @@ class DeferredUpdates {
                        }
                        MWExceptionHandler::rollbackMasterChangesAndLog( $e );
 
+                       // Try to push the update as a job so it can run later perhaps
+                       if ( $mode !== 'enqueue' && $update instanceof EnqueueableDataUpdate ) {
+                               try {
+                                       $spec = $update->getAsJobSpecification();
+                                       JobQueueGroup::singleton( $spec['wiki'] )->push( $spec['job'] );
+                               } catch ( Exception $e ) {
+                                       MWExceptionHandler::rollbackMasterChangesAndLog( $e );
+                               }
+                       }
+
                        // VW-style hack to work around T190178, so we can make sure
                        // PageMetaDataUpdater doesn't throw exceptions.
                        if ( defined( 'MW_PHPUNIT_TEST' ) ) {