Browse Source

[ZF-7196] Zend_Session_Abstract::_namespaceUnset() always unsets the whole namespace

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23373 44c647ce-9c0f-0410-b52a-842ac1e357ba
jan 15 years ago
parent
commit
92a9ff5134

+ 1 - 1
library/Zend/Session/Abstract.php

@@ -120,7 +120,7 @@ abstract class Zend_Session_Abstract
             unset(self::$_expiringData[$namespace]);
         } else {
             unset($_SESSION[$namespace][$name]);
-            unset(self::$_expiringData[$namespace]);
+            unset(self::$_expiringData[$namespace][$name]);
         }
 
         // if we remove the last value, remove namespace.

+ 23 - 0
tests/Zend/Session/SessionTest.php

@@ -891,6 +891,29 @@ class Zend_SessionTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * @group ZF-7196
+     * @runInSeparateProcess
+     */
+    public function testUnsettingNamespaceKeyWithoutUnsettingCompleteExpirationData()
+    {
+        $namespace = new Zend_Session_Namespace('DummyNamespace');
+
+        $namespace->foo = 23;
+        $namespace->bar = 42;
+
+        $namespace->setExpirationHops(1);
+
+        $sessionId = session_id();
+
+        session_write_close();
+        exec($this->_script . ' expireAll ' . $sessionId . ' DummyNamespace ZF-7196', $result, $returnValue);
+        session_start();
+
+        $result = $this->sortResult($result);
+        $this->assertSame(';bar === 42', $result);
+    }
+
+    /**
      * test expiration of namespace variables by hops; expect expiration of specified keys in the proper number of hops
      *
      * @return void

+ 3 - 0
tests/Zend/Session/SessionTestHelper.php

@@ -94,6 +94,9 @@ class Zend_Session_TestHelper
         else {
             $s = new Zend_Session_Namespace();
         }
+        if (isset($args[2]) && ($args[2] == 'ZF-7196')) {
+            unset($s->foo);
+        }
         $result = '';
         foreach ($s->getIterator() as $key => $val) {
             $result .= "$key === $val;";