فهرست منبع

Merge pull request #149 from jeremyquinton/125

Fixes #125 by using array_key_exists instead of isset
Frank Brückner 12 سال پیش
والد
کامیت
67de626940
3فایلهای تغییر یافته به همراه29 افزوده شده و 2 حذف شده
  1. 3 0
      library/Zend/Cache/Backend/Test.php
  2. 2 1
      library/Zend/Cache/Frontend/Class.php
  3. 24 1
      tests/Zend/Cache/ClassFrontendTest.php

+ 3 - 0
library/Zend/Cache/Backend/Test.php

@@ -125,6 +125,9 @@ class Zend_Cache_Backend_Test extends Zend_Cache_Backend implements Zend_Cache_B
           || $id == '4a923ef02d7f997ca14d56dfeae25ea7') {
             return serialize(array('foo', 'bar'));
         }
+        if ( $id == 'f53c7d912cc523d9a65834c8286eceb9') {
+            return serialize(array('foobar'));
+        }
         return 'foo';
     }
 

+ 2 - 1
library/Zend/Cache/Frontend/Class.php

@@ -216,7 +216,8 @@ class Zend_Cache_Frontend_Class extends Zend_Cache_Core
         }
 
         $id = $this->_makeId($name, $parameters);
-        if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1]) ) {
+        if ( ($rs = $this->load($id)) && (array_key_exists(0, $rs)) 
+                                      && (array_key_exists(1, $rs)) ) {
             // A cache is available
             $output = $rs[0];
             $return = $rs[1];

+ 24 - 1
tests/Zend/Cache/ClassFrontendTest.php

@@ -54,12 +54,20 @@ class test {
         return "foobar2_return($param1, $param2)";
     }
 
+    public function foobar3($param1, $param2)
+    {
+        echo $this->dummyMethod($param1, $param2);
+    }
+
+    private function dummyMethod($param1, $param2) {
+        return "foobar_output($param1,$param2)";
+    }
+
     public function throwException()
     {
         echo 'throw exception';
         throw new Exception('test exception');
     }
-
 }
 
 /**
@@ -220,6 +228,21 @@ class Zend_Cache_ClassFrontendTest extends PHPUnit_Framework_TestCase {
         $this->assertEquals('foobar_output(param1, param2)', $data);
     }
 
+    public function testCallCorrectCall8()
+    {
+        $this->_instance2->setOption('cache_by_default', true);
+        $this->_instance2->setOption('cached_methods', array('foobar3'));
+        ob_start();
+        ob_implicit_flush(false);
+        $return = $this->_instance2->foobar3('param1', 'param2');
+        $data = ob_get_clean();
+        ob_implicit_flush(true);
+
+        $this->assertNull($return);
+        $this->assertEquals('foobar_output(param1,param2)',$data);
+      
+    }
+
     public function testConstructorWithABadCachedEntity()
     {
         try {