Skip to content
This repository was archived by the owner on May 16, 2018. It is now read-only.

Allow overriding cache id and tag validation in Zend_Cache #487

Merged
merged 1 commit into from
Jan 9, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions library/Zend/Cache/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = f
}
$id = $this->_id($id); // cache id may need prefix
$this->_lastId = $id;
self::_validateIdOrTag($id);
$this->_validateIdOrTag($id);

$this->_log("Zend_Cache_Core: load item '{$id}'", 7);
$data = $this->_backend->load($id, $doNotTestCacheValidity);
Expand All @@ -327,7 +327,7 @@ public function test($id)
return false;
}
$id = $this->_id($id); // cache id may need prefix
self::_validateIdOrTag($id);
$this->_validateIdOrTag($id);
$this->_lastId = $id;

$this->_log("Zend_Cache_Core: test item '{$id}'", 7);
Expand Down Expand Up @@ -355,8 +355,8 @@ public function save($data, $id = null, $tags = array(), $specificLifetime = fal
} else {
$id = $this->_id($id);
}
self::_validateIdOrTag($id);
self::_validateTagsArray($tags);
$this->_validateIdOrTag($id);
$this->_validateTagsArray($tags);
if ($this->_options['automatic_serialization']) {
// we need to serialize datas before storing them
$data = serialize($data);
Expand Down Expand Up @@ -424,7 +424,7 @@ public function remove($id)
return true;
}
$id = $this->_id($id); // cache id may need prefix
self::_validateIdOrTag($id);
$this->_validateIdOrTag($id);

$this->_log("Zend_Cache_Core: remove item '{$id}'", 7);
return $this->_backend->remove($id);
Expand Down Expand Up @@ -460,7 +460,7 @@ public function clean($mode = 'all', $tags = array())
Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG))) {
Zend_Cache::throwException('Invalid cleaning mode');
}
self::_validateTagsArray($tags);
$this->_validateTagsArray($tags);

return $this->_backend->clean($mode, $tags);
}
Expand Down Expand Up @@ -667,7 +667,7 @@ public function touch($id, $extraLifetime)
* @throws Zend_Cache_Exception
* @return void
*/
protected static function _validateIdOrTag($string)
protected function _validateIdOrTag($string)
{
if (!is_string($string)) {
Zend_Cache::throwException('Invalid id or tag : must be a string');
Expand All @@ -689,13 +689,13 @@ protected static function _validateIdOrTag($string)
* @throws Zend_Cache_Exception
* @return void
*/
protected static function _validateTagsArray($tags)
protected function _validateTagsArray($tags)
{
if (!is_array($tags)) {
Zend_Cache::throwException('Invalid tags array : must be an array');
}
foreach($tags as $tag) {
self::_validateIdOrTag($tag);
$this->_validateIdOrTag($tag);
}
reset($tags);
}
Expand Down