From 04f50ad2edae27787e0d5bc43a305c2d829b72c7 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 27 Oct 2011 23:34:54 +0000 Subject: [PATCH] Reverted r84395,r98710: thumbnails must be purged on file deletion --- includes/DefaultSettings.php | 6 ------ includes/filerepo/File.php | 3 +-- includes/filerepo/ForeignAPIFile.php | 16 +++------------- includes/filerepo/LocalFile.php | 25 +++++-------------------- includes/media/Generic.php | 10 ---------- 5 files changed, 9 insertions(+), 51 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 1491f3b61f..7b296c4aab 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4836,12 +4836,6 @@ $wgJobClasses = array( 'uploadFromUrl' => 'UploadFromUrlJob', ); -/** - * Extensions of "thumbnails" that are very expensive to regenerate and should be - * excluded from normal action=purge thumbnail removal. - */ -$wgExcludeFromThumbnailPurge = array(); - /** * Jobs that must be explicitly requested, i.e. aren't run by job runners unless special flags are set. diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 2fe73cce36..63719eeffc 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -811,9 +811,8 @@ abstract class File { * Purge shared caches such as thumbnails and DB data caching * STUB * Overridden by LocalFile - * @param array $options Array with options, currently undefined */ - function purgeCache( $options = array() ) {} + function purgeCache() {} /** * Purge the file description page, but don't go after diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index e027dddc6d..ba699beec0 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -209,11 +209,8 @@ class ForeignAPIFile extends File { return $files; } - /** - * @see File::purgeCache() - */ - function purgeCache( $options = array() ) { - $this->purgeThumbnails( $options ); + function purgeCache() { + $this->purgeThumbnails(); $this->purgeDescriptionPage(); } @@ -224,18 +221,11 @@ class ForeignAPIFile extends File { $wgMemc->delete( $key ); } - function purgeThumbnails( $options = array() ) { + function purgeThumbnails() { global $wgMemc; $key = $this->repo->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $this->getName() ); $wgMemc->delete( $key ); - $files = $this->getThumbnails(); - // Give media handler a chance to filter the purge list - $handler = $this->getHandler(); - if ( $handler ) { - $handler->filterThumbnailPurgeList( $files, $options ); - } - $dir = $this->getThumbPath( $this->getName() ); foreach ( $files as $file ) { unlink( $dir . $file ); diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 460ed2751a..c26812a9fe 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -674,12 +674,12 @@ class LocalFile extends File { /** * Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid */ - function purgeCache( $options = array() ) { + function purgeCache() { // Refresh metadata cache $this->purgeMetadataCache(); // Delete thumbnails - $this->purgeThumbnails( $options ); + $this->purgeThumbnails(); // Purge squid cache for this file SquidUpdate::purge( array( $this->getURL() ) ); @@ -722,18 +722,11 @@ class LocalFile extends File { /** * Delete cached transformed files for the current version only. */ - function purgeThumbnails( $options = array() ) { + function purgeThumbnails() { global $wgUseSquid; - - // Get a list of thumbnails and URLs + + // Delete thumbnails $files = $this->getThumbnails(); - - // Give media handler a chance to filter the purge list - $handler = $this->getHandler(); - if ( $handler ) { - $handler->filterThumbnailPurgeList( $files, $options ); - } - $dir = array_shift( $files ); $this->purgeThumbList( $dir, $files ); @@ -756,16 +749,8 @@ class LocalFile extends File { * @param $files array of strings: relative filenames (to $dir) */ protected function purgeThumbList($dir, $files) { - global $wgExcludeFromThumbnailPurge; - wfDebug( __METHOD__ . ": " . var_export( $files, true ) . "\n" ); foreach ( $files as $file ) { - // Only remove files not in the $wgExcludeFromThumbnailPurge configuration variable - $ext = pathinfo( "$dir/$file", PATHINFO_EXTENSION ); - if ( in_array( $ext, $wgExcludeFromThumbnailPurge ) ) { - continue; - } - # Check that the base file name is part of the thumb name # This is a basic sanity check to avoid erasing unrelated directories if ( strpos( $file, $this->getName() ) !== false ) { diff --git a/includes/media/Generic.php b/includes/media/Generic.php index 12f35db5d4..5cd5a20bde 100644 --- a/includes/media/Generic.php +++ b/includes/media/Generic.php @@ -504,16 +504,6 @@ abstract class MediaHandler { } return false; } - - /** - * Remove files from the purge list - * - * @param array $files - * @param array $options - */ - public function filterThumbnailPurgeList( &$files, $options ) { - // Do nothing - } } /** -- 2.20.1