From 10d877dfe81d3f534a410619c1f201f37669487d Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Mon, 15 Apr 2013 20:06:23 -0300 Subject: [PATCH] RefreshLinks on imagelinks on new uploads to kill tracking cat. 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 | 2 ++ includes/LinksUpdate.php | 26 ++++++++++++++++++++------ includes/filerepo/file/LocalFile.php | 6 ++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index c46d3270fc..5339514d05 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -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 diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 4b1b5b888c..0b7393addb 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -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__ ); } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 3cb1f41e72..b21b87ab10 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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(); } -- 2.20.1