r101088 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101087‎ | r101088 | r101089 >
Date:23:34, 27 October 2011
Author:aaron
Status:ok
Tags:
Comment:
Reverted r84395,r98710: thumbnails must be purged on file deletion
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/filerepo/File.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIFile.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)
  • /trunk/phase3/includes/media/Generic.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -674,12 +674,12 @@
675675 /**
676676 * Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid
677677 */
678 - function purgeCache( $options = array() ) {
 678+ function purgeCache() {
679679 // Refresh metadata cache
680680 $this->purgeMetadataCache();
681681
682682 // Delete thumbnails
683 - $this->purgeThumbnails( $options );
 683+ $this->purgeThumbnails();
684684
685685 // Purge squid cache for this file
686686 SquidUpdate::purge( array( $this->getURL() ) );
@@ -722,18 +722,11 @@
723723 /**
724724 * Delete cached transformed files for the current version only.
725725 */
726 - function purgeThumbnails( $options = array() ) {
 726+ function purgeThumbnails() {
727727 global $wgUseSquid;
728 -
729 - // Get a list of thumbnails and URLs
 728+
 729+ // Delete thumbnails
730730 $files = $this->getThumbnails();
731 -
732 - // Give media handler a chance to filter the purge list
733 - $handler = $this->getHandler();
734 - if ( $handler ) {
735 - $handler->filterThumbnailPurgeList( $files, $options );
736 - }
737 -
738731 $dir = array_shift( $files );
739732 $this->purgeThumbList( $dir, $files );
740733
@@ -756,16 +749,8 @@
757750 * @param $files array of strings: relative filenames (to $dir)
758751 */
759752 protected function purgeThumbList($dir, $files) {
760 - global $wgExcludeFromThumbnailPurge;
761 -
762753 wfDebug( __METHOD__ . ": " . var_export( $files, true ) . "\n" );
763754 foreach ( $files as $file ) {
764 - // Only remove files not in the $wgExcludeFromThumbnailPurge configuration variable
765 - $ext = pathinfo( "$dir/$file", PATHINFO_EXTENSION );
766 - if ( in_array( $ext, $wgExcludeFromThumbnailPurge ) ) {
767 - continue;
768 - }
769 -
770755 # Check that the base file name is part of the thumb name
771756 # This is a basic sanity check to avoid erasing unrelated directories
772757 if ( strpos( $file, $this->getName() ) !== false ) {
Index: trunk/phase3/includes/filerepo/File.php
@@ -811,9 +811,8 @@
812812 * Purge shared caches such as thumbnails and DB data caching
813813 * STUB
814814 * Overridden by LocalFile
815 - * @param array $options Array with options, currently undefined
816815 */
817 - function purgeCache( $options = array() ) {}
 816+ function purgeCache() {}
818817
819818 /**
820819 * Purge the file description page, but don't go after
Index: trunk/phase3/includes/filerepo/ForeignAPIFile.php
@@ -209,11 +209,8 @@
210210 return $files;
211211 }
212212
213 - /**
214 - * @see File::purgeCache()
215 - */
216 - function purgeCache( $options = array() ) {
217 - $this->purgeThumbnails( $options );
 213+ function purgeCache() {
 214+ $this->purgeThumbnails();
218215 $this->purgeDescriptionPage();
219216 }
220217
@@ -224,18 +221,11 @@
225222 $wgMemc->delete( $key );
226223 }
227224
228 - function purgeThumbnails( $options = array() ) {
 225+ function purgeThumbnails() {
229226 global $wgMemc;
230227 $key = $this->repo->getLocalCacheKey( 'ForeignAPIRepo', 'ThumbUrl', $this->getName() );
231228 $wgMemc->delete( $key );
232 -
233229 $files = $this->getThumbnails();
234 - // Give media handler a chance to filter the purge list
235 - $handler = $this->getHandler();
236 - if ( $handler ) {
237 - $handler->filterThumbnailPurgeList( $files, $options );
238 - }
239 -
240230 $dir = $this->getThumbPath( $this->getName() );
241231 foreach ( $files as $file ) {
242232 unlink( $dir . $file );
Index: trunk/phase3/includes/media/Generic.php
@@ -504,16 +504,6 @@
505505 }
506506 return false;
507507 }
508 -
509 - /**
510 - * Remove files from the purge list
511 - *
512 - * @param array $files
513 - * @param array $options
514 - */
515 - public function filterThumbnailPurgeList( &$files, $options ) {
516 - // Do nothing
517 - }
518508 }
519509
520510 /**
Index: trunk/phase3/includes/DefaultSettings.php
@@ -4837,13 +4837,7 @@
48384838 );
48394839
48404840 /**
4841 - * Extensions of "thumbnails" that are very expensive to regenerate and should be
4842 - * excluded from normal action=purge thumbnail removal.
4843 - */
4844 -$wgExcludeFromThumbnailPurge = array();
48454841
4846 -/**
4847 -
48484842 * Jobs that must be explicitly requested, i.e. aren't run by job runners unless special flags are set.
48494843 *
48504844 * These can be:

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84395(bug 27641) purgeThumbnails should support exclusion of expensive files. Add ...catrope16:38, 20 March 2011
r98710Follow-up r84395: Give MediaHandlers the option to remove items from the thum...btongminh20:08, 2 October 2011

Status & tagging log