mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Tag-less cache backends error on flush
This commit is contained in:
parent
73c52a6eeb
commit
570f261302
@ -101,7 +101,18 @@ class i18n extends Object implements TemplateGlobalProvider, Flushable {
|
||||
* Triggered early in the request when someone requests a flush.
|
||||
*/
|
||||
public static function flush() {
|
||||
self::get_cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Zend_Translate'));
|
||||
$cache = self::get_cache();
|
||||
$backend = $cache->getBackend();
|
||||
|
||||
if(
|
||||
$backend instanceof Zend_Cache_Backend_ExtendedInterface
|
||||
&& ($capabilities = $backend->getCapabilities())
|
||||
&& $capabilities['tags']
|
||||
) {
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, $cache->getTags());
|
||||
} else {
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,15 +50,22 @@ class Aggregate extends ViewableData {
|
||||
*/
|
||||
public static function flushCache($class=null) {
|
||||
$cache = self::cache();
|
||||
$capabilities = $cache->getBackend()->getCapabilities();
|
||||
if($capabilities['tags'] && (!$class || $class == 'DataObject')) {
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('aggregate'));
|
||||
} elseif($capabilities['tags']) {
|
||||
$tags = ClassInfo::ancestry($class);
|
||||
foreach($tags as &$tag) {
|
||||
$tag = preg_replace('/[^a-zA-Z0-9_]/', '_', $tag);
|
||||
$backend = $cache->getBackend();
|
||||
|
||||
if(
|
||||
$backend instanceof Zend_Cache_Backend_ExtendedInterface
|
||||
&& ($capabilities = $backend->getCapabilities())
|
||||
&& $capabilities['tags']
|
||||
) {
|
||||
if( ! $class || $class == 'DataObject') {
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('aggregate'));
|
||||
} else {
|
||||
$tags = ClassInfo::ancestry($class);
|
||||
foreach($tags as &$tag) {
|
||||
$tag = preg_replace('/[^a-zA-Z0-9_]/', '_', $tag);
|
||||
}
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
|
||||
}
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
|
||||
} else {
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
}
|
||||
|
@ -948,8 +948,19 @@ class SSViewer implements Flushable {
|
||||
public static function flush_cacheblock_cache($force = false) {
|
||||
if (!self::$cacheblock_cache_flushed || $force) {
|
||||
$cache = SS_Cache::factory('cacheblock');
|
||||
$tags = $cache->getTags();
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, $tags);
|
||||
$backend = $cache->getBackend();
|
||||
|
||||
if(
|
||||
$backend instanceof Zend_Cache_Backend_ExtendedInterface
|
||||
&& ($capabilities = $backend->getCapabilities())
|
||||
&& $capabilities['tags']
|
||||
) {
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, $cache->getTags());
|
||||
} else {
|
||||
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
|
||||
}
|
||||
|
||||
|
||||
self::$cacheblock_cache_flushed = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user