Procházet zdrojové kódy

Allows interpretation of a lifetime setting set to an empty string as NULL - required to support INI configuration. Fixes ZF-9092

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20929 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic před 16 roky
rodič
revize
f003dfda9b
2 změnil soubory, kde provedl 14 přidání a 0 odebrání
  1. 3 0
      library/Zend/Cache/Core.php
  2. 11 0
      tests/Zend/Cache/CoreTest.php

+ 3 - 0
library/Zend/Cache/Core.php

@@ -262,6 +262,9 @@ class Zend_Cache_Core
         if (!is_string($name) || !array_key_exists($name, $this->_options)) {
             Zend_Cache::throwException("Incorrect option name : $name");
         }
+        if ($name == 'lifetime' && empty($value)) {
+            $value = null;
+        }
         $this->_options[$name] = $value;
     }
 

+ 11 - 0
tests/Zend/Cache/CoreTest.php

@@ -86,6 +86,17 @@ class Zend_Cache_CoreTest extends PHPUnit_Framework_TestCase
         $test->setConfig($config);
         $this->assertEquals(3600, $test->getOption('lifetime'));
     }
+    
+    /**
+     * @group ZF-9092
+     */
+    public function testSettingLifetimeAsEmptyIsInterpretedAsNull()
+    {
+        $config = new Zend_Config(array('lifetime' => '', 'caching' => true));
+        $test = new Zend_Cache_Core();
+        $test->setConfig($config);
+        $this->assertSame(NULL, $test->getOption('lifetime'));
+    }
 
     public function testConstructorBadOption()
     {