mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Sanitise keys and tags before using them with Zend_Cache.
This commit is contained in:
parent
27a51ed7ed
commit
f7516481b1
@ -48,9 +48,12 @@ class Aggregate extends ViewableData {
|
|||||||
|
|
||||||
if (!$class || $class == 'DataObject') {
|
if (!$class || $class == 'DataObject') {
|
||||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('aggregate'));
|
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('aggregate'));
|
||||||
}
|
} else {
|
||||||
else {
|
$tags = ClassInfo::ancestry($class);
|
||||||
$cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +111,7 @@ class Aggregate extends ViewableData {
|
|||||||
|
|
||||||
if (!($result = $cache->load($cachekey))) {
|
if (!($result = $cache->load($cachekey))) {
|
||||||
$result = (string)$query->execute()->value(); if (!$result) $result = '0';
|
$result = (string)$query->execute()->value(); if (!$result) $result = '0';
|
||||||
$cache->save($result, null, array('aggregate', $this->type));
|
$cache->save($result, null, array('aggregate', preg_replace('/[^a-zA-Z0-9_]/', '_', $this->type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -490,6 +490,7 @@ class SSTemplateParser extends Parser {
|
|||||||
$block = ++$res['subblocks'];
|
$block = ++$res['subblocks'];
|
||||||
// Build the key for this block from the passed cache key, the block index, and the sha hash of the template itself
|
// Build the key for this block from the passed cache key, the block index, and the sha hash of the template itself
|
||||||
$key = "'" . sha1($sub['php']) . (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") . ".'_$block'";
|
$key = "'" . sha1($sub['php']) . (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") . ".'_$block'";
|
||||||
|
$key = preg_replace('/[^a-zA-Z0-9_]/', '_', $key);
|
||||||
// Get any condition
|
// Get any condition
|
||||||
$condition = isset($res['condition']) ? $res['condition'] : '';
|
$condition = isset($res['condition']) ? $res['condition'] : '';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user