Merge "Improvements to RefreshLinksJob/DeleteLinksJob locking"
[lhc/web/wiklou.git] / includes / deferred / DataUpdate.php
index 9cbb62f..2865461 100644 (file)
@@ -31,7 +31,7 @@
  */
 abstract class DataUpdate implements DeferrableUpdate {
        public function __construct() {
-               //noop
+               // noop
        }
 
        /**
@@ -39,7 +39,7 @@ abstract class DataUpdate implements DeferrableUpdate {
         * This default implementation does nothing.
         */
        public function beginTransaction() {
-               //noop
+               // noop
        }
 
        /**
@@ -47,7 +47,7 @@ abstract class DataUpdate implements DeferrableUpdate {
         * This default implementation does nothing.
         */
        public function commitTransaction() {
-               //noop
+               // noop
        }
 
        /**
@@ -55,7 +55,7 @@ abstract class DataUpdate implements DeferrableUpdate {
         * This default implementation does nothing.
         */
        public function rollbackTransaction() {
-               //noop
+               // noop
        }
 
        /**
@@ -84,7 +84,7 @@ abstract class DataUpdate implements DeferrableUpdate {
                        return; // nothing to do
                }
 
-               $open_transactions = array();
+               $open_transactions = [];
                $exception = null;
 
                try {
@@ -127,14 +127,15 @@ abstract class DataUpdate implements DeferrableUpdate {
         *
         * @param DataUpdate[] $updates A list of DataUpdate instances
         * @return DataUpdate[]
-        * @since 1.26
+        * @since 1.27
         */
        protected static function enqueueUpdates( array $updates ) {
-               $remaining = array();
+               $remaining = [];
 
                foreach ( $updates as $update ) {
                        if ( $update instanceof EnqueueableDataUpdate ) {
-                               $update->enqueueUpdate();
+                               $spec = $update->getAsJobSpecification();
+                               JobQueueGroup::singleton( $spec['wiki'] )->push( $spec['job'] );
                        } else {
                                $remaining[] = $update;
                        }
@@ -145,12 +146,16 @@ abstract class DataUpdate implements DeferrableUpdate {
 }
 
 /**
- * @since 1.26
+ * 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.27
  */
 interface EnqueueableDataUpdate {
        /**
-        * Push the update into the job queue
+        * @return array (wiki => wiki ID, job => IJobSpecification)
         */
-       public function enqueueUpdate();
+       public function getAsJobSpecification();
 }
-