Page MenuHomePhabricator

wgExcludeFromThumbnailPurge.patch

Authored By
bzimport
Nov 21 2014, 11:29 PM
Size
1 KB
Referenced Files
None
Subscribers
None

wgExcludeFromThumbnailPurge.patch

Index: includes/DefaultSettings.php
===================================================================
--- includes/DefaultSettings.php (revision 83265)
+++ includes/DefaultSettings.php (working copy)
@@ -4619,6 +4619,12 @@
);
/**
+ * Extension 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: includes/filerepo/LocalFile.php
===================================================================
--- includes/filerepo/LocalFile.php (revision 83265)
+++ includes/filerepo/LocalFile.php (working copy)
@@ -659,7 +659,7 @@
* Delete cached transformed files
*/
function purgeThumbnails() {
- global $wgUseSquid;
+ global $wgUseSquid, $wgExcludeFromThumbnailPurge;
// Delete thumbnails
$files = $this->getThumbnails();
@@ -667,6 +667,12 @@
$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 ) {

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7141
Default Alt Text
wgExcludeFromThumbnailPurge.patch (1 KB)

Event Timeline