Skip to content

Commit

Permalink
Allow overriding cache id and tag validation in Zend_Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
froschdesign authored and antonis179 committed Jan 11, 2018
1 parent 3225c63 commit bc859d6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions library/Zend/Cache/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,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 @@ -310,7 +310,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 @@ -338,8 +338,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 @@ -408,7 +408,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 @@ -444,7 +444,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 @@ -651,7 +651,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 @@ -673,13 +673,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

0 comments on commit bc859d6

Please sign in to comment.