Set getDeduplicationInfo() for HTMLCacheUpdateJob
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 19 Oct 2017 19:39:56 +0000 (12:39 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 20 Oct 2017 05:38:58 +0000 (22:38 -0700)
This allows de-duplication of single page jobs for the
same page due to edits to different templates. This is
the same logic that RefreshLinksJob already has.

Also fix a bug in that method in RefreshLinksJob.

Change-Id: I2f79031c945eb3d195f9dbda949077bbc3e67918

includes/jobqueue/jobs/HTMLCacheUpdateJob.php
includes/jobqueue/jobs/RefreshLinksJob.php

index e8edab5..4d75cb3 100644 (file)
@@ -169,6 +169,20 @@ class HTMLCacheUpdateJob extends Job {
                }
        }
 
+       public function getDeduplicationInfo() {
+               $info = parent::getDeduplicationInfo();
+               if ( is_array( $info['params'] ) ) {
+                       // For per-pages jobs, the job title is that of the template that changed
+                       // (or similar), so remove that since it ruins duplicate detection
+                       if ( isset( $info['params']['pages'] ) ) {
+                               unset( $info['namespace'] );
+                               unset( $info['title'] );
+                       }
+               }
+
+               return $info;
+       }
+
        public function workItemCount() {
                if ( !empty( $this->params['recursive'] ) ) {
                        return 0; // nothing actually purged
index 424fcec..51e964d 100644 (file)
@@ -291,7 +291,7 @@ class RefreshLinksJob extends Job {
                if ( is_array( $info['params'] ) ) {
                        // For per-pages jobs, the job title is that of the template that changed
                        // (or similar), so remove that since it ruins duplicate detection
-                       if ( isset( $info['pages'] ) ) {
+                       if ( isset( $info['params']['pages'] ) ) {
                                unset( $info['namespace'] );
                                unset( $info['title'] );
                        }