Added array $options to File::purgeCache(), LocalFile::purgeCache(), LocalFile::purgeThumbnails(), ForeignAPIFile::purgeCache() and ForeignAPIFile::purgeThumbnails() which is currently empty, but can be used later to indicate a full or partial purge.
Added MediaHandler::filterThumbnailPurgeList(), which can remove items from the purge list and also gets passed this $options array
* Purge shared caches such as thumbnails and DB data caching
* STUB
* Overridden by LocalFile
+ * @param array $options Array with options, currently undefined
*/
- function purgeCache() {}
+ function purgeCache( $options = array() ) {}
/**
* Purge the file description page, but don't go after
return $files;
}
- function purgeCache() {
- $this->purgeThumbnails();
+ /**
+ * @see File::purgeCache()
+ */
+ function purgeCache( $options = array() ) {
+ $this->purgeThumbnails( $options );
$this->purgeDescriptionPage();
}
$wgMemc->delete( $key );
}
- function purgeThumbnails() {
+ function purgeThumbnails( $options = array() ) {
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 );
/**
* Delete all previously generated thumbnails, refresh metadata in memcached and purge the squid
*/
- function purgeCache() {
+ function purgeCache( $options = array() ) {
// Refresh metadata cache
$this->purgeMetadataCache();
// Delete thumbnails
- $this->purgeThumbnails();
+ $this->purgeThumbnails( $options );
// Purge squid cache for this file
SquidUpdate::purge( array( $this->getURL() ) );
/**
* Delete cached transformed files for the current version only.
*/
- function purgeThumbnails() {
+ function purgeThumbnails( $options = array() ) {
global $wgUseSquid;
- // get a list of thumbnails and URLs
+
+ // Get a list of thumbnails and URLs
$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 );
}
return false;
}
+
+ /**
+ * Remove files from the purge list
+ *
+ * @param array $files
+ * @param array $options
+ */
+ public function filterThumbnailPurgeList( &$files, $options ) {
+ // Do nothing
+ }
}
/**