Don't purge thumbs for old versions of an image during ?action=purge
authorBrian Wolff <bawolff+wn@gmail.com>
Tue, 9 Jul 2013 16:32:08 +0000 (13:32 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Tue, 9 Jul 2013 23:13:07 +0000 (23:13 +0000)
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
includes/revisiondelete/RevisionDelete.php

index 3be66d3..6e0769e 100644 (file)
@@ -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__ );
        }
 
        /**
index ac72276..135e31f 100644 (file)
@@ -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();
        }