(bug 27641) purgeThumbnails should support exclusion of expensive files. Add $wgExclu...
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 20 Mar 2011 16:38:08 +0000 (16:38 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 20 Mar 2011 16:38:08 +0000 (16:38 +0000)
includes/DefaultSettings.php
includes/filerepo/LocalFile.php

index e25bed0..e1c1806 100644 (file)
@@ -4645,6 +4645,12 @@ $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();
+
 /**
  * Additional functions to be performed with updateSpecialPages.
  * Expensive Querypages are already updated.
index 6e57ca0..d495c00 100644 (file)
@@ -659,7 +659,7 @@ class LocalFile extends File {
         * Delete cached transformed files
         */
        function purgeThumbnails() {
-               global $wgUseSquid;
+               global $wgUseSquid, $wgExcludeFromThumbnailPurge;
 
                // Delete thumbnails
                $files = $this->getThumbnails();
@@ -667,6 +667,12 @@ class LocalFile extends File {
                $urls = array();
 
                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 ) {