From 5239b2db2d226a2623d02a66f0e84b32ee314e14 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Tue, 9 Jul 2013 13:32:08 -0300 Subject: [PATCH] Don't purge thumbs for old versions of an image during ?action=purge This tends to become extremely expensive as the number of oldversions of a file increase. It is also not generally needed since ?action=purge is usually targeting the current version (additionally old versions of the file have fixed urls, so they're less likely to get out of sync). If an old version does need to be purged, one can revdel and un-revdel it. It should be noted that this extra purging was added for bug 30192. However, since that bug was fixed, most of the places requiring purging of old thumbnails have now done it directly instead of by relying on $file->purgeCache. The exception being revision deletion, which still assumes $file->purgeCache clears the thumbnails of old versions of the file. There's no real bug for this, but I kind of hijacked bug 49362 Change-Id: Ib399132cabe79fd2b4b23bad5708bfa50b282074 --- includes/filerepo/file/LocalFile.php | 17 ++++++++++------- includes/revisiondelete/RevisionDelete.php | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 3be66d3ff3..6e0769e48d 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -798,7 +798,9 @@ class LocalFile extends File { } /** - * Purge the shared history (OldLocalFile) cache + * Purge the shared history (OldLocalFile) cache. + * + * @note This used to purge old thumbnails as well. */ function purgeHistory() { global $wgMemc; @@ -806,20 +808,20 @@ class LocalFile extends File { $hashedName = md5( $this->getName() ); $oldKey = $this->repo->getSharedCacheKey( 'oldfile', $hashedName ); - // Must purge thumbnails for old versions too! bug 30192 - foreach ( $this->getHistory() as $oldFile ) { - $oldFile->purgeThumbnails(); - } - if ( $oldKey ) { $wgMemc->delete( $oldKey ); } } /** - * Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid + * Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid. + * + * @param Array $options An array potentially with the key forThumbRefresh. + * + * @note This used to purge old thumbnails by default as well, but doesn't anymore. */ function purgeCache( $options = array() ) { + wfProfileIn( __METHOD__ ); // Refresh metadata cache $this->purgeMetadataCache(); @@ -828,6 +830,7 @@ class LocalFile extends File { // Purge squid cache for this file SquidUpdate::purge( array( $this->getURL() ) ); + wfProfileOut( __METHOD__ ); } /** diff --git a/includes/revisiondelete/RevisionDelete.php b/includes/revisiondelete/RevisionDelete.php index ac722769b8..135e31ff67 100644 --- a/includes/revisiondelete/RevisionDelete.php +++ b/includes/revisiondelete/RevisionDelete.php @@ -501,6 +501,9 @@ class RevDel_FileList extends RevDel_List { $file = wfLocalFile( $this->title ); $file->purgeCache(); $file->purgeDescription(); + foreach ( $this->ids as $timestamp ) { + $file->purgeOldThumbnails( $timestamp . '!' . $this->title->getDBkey() ); + } return Status::newGood(); } -- 2.20.1