Merge "(bug 43661) Added test for special link trail case"
[lhc/web/wiklou.git] / includes / job / Job.php
index 0d2803e..927ca4e 100644 (file)
@@ -178,6 +178,51 @@ abstract class Job {
                return $this->removeDuplicates;
        }
 
+       /**
+        * Subclasses may need to override this to make duplication detection work
+        *
+        * @return Array Map of key/values
+        */
+       public function getDeduplicationInfo() {
+               $info = array(
+                       'type'      => $this->getType(),
+                       'namespace' => $this->getTitle()->getNamespace(),
+                       'title'     => $this->getTitle()->getDBkey(),
+                       'params'    => $this->getParams()
+               );
+               // Identical jobs with different "root" jobs should count as duplicates
+               if ( is_array( $info['params'] ) ) {
+                       unset( $info['params']['rootJobSignature'] );
+                       unset( $info['params']['rootJobTimestamp'] );
+               }
+               return $info;
+       }
+
+       /**
+        * @param $key string A key that identifies the task
+        * @return Array
+        */
+       public static function newRootJobParams( $key ) {
+               return array(
+                       'rootJobSignature' => sha1( $key ),
+                       'rootJobTimestamp' => wfTimestampNow()
+               );
+       }
+
+       /**
+        * @return Array
+        */
+       public function getRootJobParams() {
+               return array(
+                       'rootJobSignature' => isset( $this->params['rootJobSignature'] )
+                               ? $this->params['rootJobSignature']
+                               : null,
+                       'rootJobTimestamp' => isset( $this->params['rootJobTimestamp'] )
+                               ? $this->params['rootJobTimestamp']
+                               : null
+               );
+       }
+
        /**
         * Insert a single job into the queue.
         * @return bool true on success