Browse Source

ZF-5514: implemented patch and adapted test backend

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20378 44c647ce-9c0f-0410-b52a-842ac1e357ba
mabe 16 years ago
parent
commit
4d8ef704ed

+ 6 - 5
library/Zend/Cache/Backend/Test.php

@@ -103,7 +103,11 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B
     public function load($id, $doNotTestCacheValidity = false)
     {
         $this->_addLog('get', array($id, $doNotTestCacheValidity));
-        if ($id=='false') {
+        if ( $id == 'false'
+          || $id == 'd8523b3ee441006261eeffa5c3d3a0a7'
+          || $id == 'e83249ea22178277d5befc2c5e2e9ace'
+          || $id == '40f649b94977c0a6e76902e2a0b43587')
+        {
             return false;
         }
         if ($id=='serialized') {
@@ -136,10 +140,7 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B
         if ($id=='false') {
             return false;
         }
-        if (($id=='d8523b3ee441006261eeffa5c3d3a0a7') or ($id=='3c439c922209e2cb0b54d6deffccd75a')) {
-            return false;
-        }
-        if (($id=='40f649b94977c0a6e76902e2a0b43587') or ($id=='e83249ea22178277d5befc2c5e2e9ace')) {
+        if (($id=='3c439c922209e2cb0b54d6deffccd75a')) {
             return false;
         }
         return 123456;

+ 6 - 5
library/Zend/Cache/Frontend/Class.php

@@ -208,14 +208,14 @@ class Zend_Cache_Frontend_Class extends Zend_Cache_Core
             // We do not have not cache
             return call_user_func_array(array($this->_cachedEntity, $name), $parameters);
         }
+
         $id = $this->_makeId($name, $parameters);
-        if ($this->test($id)) {
+        if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1]) ) {
             // A cache is available
-            $result = $this->load($id);
-            $output = $result[0];
-            $return = $result[1];
+            $output = $rs[0];
+            $return = $rs[1];
         } else {
-            // A cache is not available
+            // A cache is not available (or not valid for this frontend)
             ob_start();
             ob_implicit_flush(false);
             $return = call_user_func_array(array($this->_cachedEntity, $name), $parameters);
@@ -224,6 +224,7 @@ class Zend_Cache_Frontend_Class extends Zend_Cache_Core
             $data = array($output, $return);
             $this->save($data, $id, $this->_tags, $this->_specificLifetime, $this->_priority);
         }
+
         echo $output;
         return $return;
     }

+ 6 - 5
library/Zend/Cache/Frontend/Function.php

@@ -89,14 +89,14 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core
             // We do not have not cache
             return call_user_func_array($name, $parameters);
         }
+
         $id = $this->_makeId($name, $parameters);
-        if ($this->test($id)) {
+        if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1])) {
             // A cache is available
-            $result = $this->load($id);
-            $output = $result[0];
-            $return = $result[1];
+            $output = $rs[0];
+            $return = $rs[1];
         } else {
-            // A cache is not available
+            // A cache is not available (or not valid for this frontend)
             ob_start();
             ob_implicit_flush(false);
             $return = call_user_func_array($name, $parameters);
@@ -105,6 +105,7 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core
             $data = array($output, $return);
             $this->save($data, $id, $tags, $specificLifetime, $priority);
         }
+
         echo $output;
         return $return;
     }