Refactored global state out of EnqueueableDataUpdate
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 24 Sep 2015 22:45:09 +0000 (15:45 -0700)
committerOri Livneh <ori@wikimedia.org>
Tue, 29 Sep 2015 21:54:15 +0000 (14:54 -0700)
* Follow-up 25a44aa3e4fa
* The static DataUpdate::enqueueUpdates() method will
  deal with JobQueueGroup construction instead

Change-Id: Id7741a770cee81fdc3f61804b7574ccf737bc338

includes/deferred/DataUpdate.php

index e07fc87..4a61b2a 100644 (file)
@@ -134,7 +134,8 @@ abstract class DataUpdate implements DeferrableUpdate {
 
                foreach ( $updates as $update ) {
                        if ( $update instanceof EnqueueableDataUpdate ) {
-                               $update->enqueueUpdate();
+                               $spec = $update->getAsJobSpecification();
+                               JobQueueGroup::singleton( $spec['wiki'] )->push( $spec['job'] );
                        } else {
                                $remaining[] = $update;
                        }
@@ -145,11 +146,16 @@ abstract class DataUpdate implements DeferrableUpdate {
 }
 
 /**
+ * Interface that marks a DataUpdate as enqueuable via the JobQueue
+ *
+ * Such updates must be representable using IJobSpecification, so that
+ * they can be serialized into jobs and enqueued for later execution
+ *
  * @since 1.26
  */
 interface EnqueueableDataUpdate {
        /**
-        * Push the update into the job queue
+        * @return array (wiki => wiki ID, job => IJobSpecification)
         */
-       public function enqueueUpdate();
+       public function getAsJobSpecification();
 }