RefreshLinks on imagelinks on new uploads to kill tracking cat.
authorBrian Wolff <bawolff+wn@gmail.com>
Mon, 15 Apr 2013 23:06:23 +0000 (20:06 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Wed, 5 Jun 2013 14:01:22 +0000 (11:01 -0300)
When someone uploads a new file, we should refresh all the pages
that use that image, so that [[Category:Pages with broken file links]]
gets removed.

Future fixme would to run this again on file deletes, but that's
less critical as they will eventually get added on next reparse
and people don't expect that to happen instantly like when fixing
the issue. Ditto for someone creating a new file redirect.

Bug: 46749
Change-Id: I7889598eee54a1c07c64f750b8499e922ba59704

RELEASE-NOTES-1.22
includes/LinksUpdate.php
includes/filerepo/file/LocalFile.php

index c46d327..5339514 100644 (file)
@@ -130,6 +130,8 @@ production.
   is disabled, and AJAX patrolling and watching are now disabled when use of
   the write API is not allowed.
 * (bug 48294) API: Fix chunk upload async mode.
+* (bug 46749) Broken files tracking category removed from pages if an image
+  with that name is uploaded.
 
 === API changes in 1.22 ===
 * (bug 46626) xmldoublequote parameter was removed. Because of a bug, the
index 4b1b5b8..0b7393a 100644 (file)
@@ -237,22 +237,36 @@ class LinksUpdate extends SqlDataUpdate {
                wfProfileOut( __METHOD__ );
        }
 
+       /**
+        * Queue recursive jobs for this page
+        *
+        * Which means do LinksUpdate on all templates
+        * that include the current page, using the job queue.
+        */
        function queueRecursiveJobs() {
-               wfProfileIn( __METHOD__ );
+               self::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
+       }
 
-               if ( $this->mTitle->getBacklinkCache()->hasLinks( 'templatelinks' ) ) {
+       /**
+        * Queue a RefreshLinks job for any table.
+        *
+        * @param Title $title Title to do job for
+        * @param String $table Table to use (e.g. 'templatelinks')
+        */
+       public static function queueRecursiveJobsForTable( Title $title, $table ) {
+               wfProfileIn( __METHOD__ );
+               if ( $title->getBacklinkCache()->hasLinks( $table ) ) {
                        $job = new RefreshLinksJob2(
-                               $this->mTitle,
+                               $title,
                                array(
-                                       'table' => 'templatelinks',
+                                       'table' => $table,
                                ) + Job::newRootJobParams( // "overall" refresh links job info
-                                       "refreshlinks:templatelinks:{$this->mTitle->getPrefixedText()}"
+                                       "refreshlinks:{$table}:{$title->getPrefixedText()}"
                                )
                        );
                        JobQueueGroup::singleton()->push( $job );
                        JobQueueGroup::singleton()->deduplicateRootJob( $job );
                }
-
                wfProfileOut( __METHOD__ );
        }
 
index 3cb1f41..b21b87a 100644 (file)
@@ -1372,11 +1372,17 @@ class LocalFile extends File {
                # Invalidate cache for all pages using this file
                $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' );
                $update->doUpdate();
+               if ( !$reupload ) {
+                       LinksUpdate::queueRecursiveJobsForTable( $this->getTitle(), 'imagelinks' );
+               }
 
                # Invalidate cache for all pages that redirects on this page
                $redirs = $this->getTitle()->getRedirectsHere();
 
                foreach ( $redirs as $redir ) {
+                       if ( !$reupload && $redir->getNamespace() === NS_FILE ) {
+                               LinksUpdate::queueRecursiveJobsForTable( $redir, 'imagelinks' );
+                       }
                        $update = new HTMLCacheUpdate( $redir, 'imagelinks' );
                        $update->doUpdate();
                }