Browse Source

ZF-10908: fixed failure process on Zend_Cache_Core::save if a cache_id_prefix is present

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23670 44c647ce-9c0f-0410-b52a-842ac1e357ba
mabe 15 years ago
parent
commit
7415146a8f

+ 2 - 2
library/Zend/Cache/Backend/Test.php

@@ -164,7 +164,7 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B
     public function save($data, $id, $tags = array(), $specificLifetime = false)
     {
         $this->_addLog('save', array($data, $id, $tags));
-        if ($id=='false') {
+        if (substr($id,-5)=='false') {
             return false;
         }
         return true;
@@ -182,7 +182,7 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B
     public function remove($id)
     {
         $this->_addLog('remove', array($id));
-        if ($id=='false') {
+        if (substr($id,-5)=='false') {
             return false;
         }
         return true;

+ 1 - 1
library/Zend/Cache/Core.php

@@ -397,7 +397,7 @@ class Zend_Cache_Core
             if ($this->_options['logging']) {
                 $this->_log("Zend_Cache_Core::save() : impossible to save cache (id=$id)");
             }
-            $this->remove($id);
+            $this->_backend->remove($id);
             return false;
         }
         if ($this->_options['write_control']) {

+ 4 - 2
tests/Zend/Cache/CoreTest.php

@@ -284,13 +284,15 @@ class Zend_Cache_CoreTest extends PHPUnit_Framework_TestCase
 
     public function testSaveCorrectCallButFileCorruption()
     {
+        $cacheIdPrefix = 'cacheIdPrefix';
+        $this->_instance->setOption('cache_id_prefix', $cacheIdPrefix);
         $res = $this->_instance->save('data', 'false', array('tag1', 'tag2'));
         $logs = $this->_backend->getAllLogs();
         $expected1 = array(
             'methodName' => 'save',
             'args' => array(
                 0 => 'data',
-                1 => 'false',
+                1 => $cacheIdPrefix . 'false',
                 2 => array(
                     0 => 'tag1',
                     1 => 'tag2'
@@ -300,7 +302,7 @@ class Zend_Cache_CoreTest extends PHPUnit_Framework_TestCase
         $expected2 = array(
             'methodName' => 'remove',
             'args' => array(
-                0 => 'false'
+                0 => $cacheIdPrefix.'false'
             )
         );
         $this->assertFalse($res);