Merge "Convert JobRunner to PSR-3 logger"
[lhc/web/wiklou.git] / includes / jobqueue / Job.php
index d01a279..334d374 100644 (file)
@@ -135,7 +135,15 @@ abstract class Job implements IJobSpecification {
        }
 
        /**
-        * @return bool Whether only one of each identical set of jobs should be run
+        * Whether the queue should reject insertion of this job if a duplicate exists
+        *
+        * This can be used to avoid duplicated effort or combined with delayed jobs to
+        * coalesce updates into larger batches. Claimed jobs are never treated as
+        * duplicates of new jobs, and some queues may allow a few duplicates due to
+        * network partitions and fail-over. Thus, additional locking is needed to
+        * enforce mutual exclusion if this is really needed.
+        *
+        * @return bool
         */
        public function ignoreDuplicates() {
                return $this->removeDuplicates;
@@ -277,13 +285,22 @@ abstract class Job implements IJobSpecification {
                        }
                }
 
-               if ( is_object( $this->title ) ) {
-                       $s = "{$this->command} {$this->title->getPrefixedDBkey()}";
-                       if ( $paramString !== '' ) {
-                               $s .= " $paramString";
+               $metaString = '';
+               foreach ( $this->metadata as $key => $value ) {
+                       if ( is_scalar( $value ) && mb_strlen( $value ) < 1024 ) {
+                               $metaString .= ( $metaString ? ",$key=$value" : "$key=$value" );
                        }
-               } else {
-                       $s = "{$this->command} $paramString";
+               }
+
+               $s = $this->command;
+               if ( is_object( $this->title ) ) {
+                       $s .= " {$this->title->getPrefixedDBkey()}";
+               }
+               if ( $paramString != '' ) {
+                       $s .= " $paramString";
+               }
+               if ( $metaString != '' ) {
+                       $s .= " ($metaString)";
                }
 
                return $s;