From eae50fd684080cb78aac32d1765882abe3c192f8 Mon Sep 17 00:00:00 2001 From: Zacharias Luiten Date: Thu, 17 Jan 2013 10:09:02 +0100 Subject: [PATCH] fix for zendframework/zf2#3458 --- library/Zend/Session/SessionManager.php | 2 +- tests/ZendTest/Session/SessionManagerTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/library/Zend/Session/SessionManager.php b/library/Zend/Session/SessionManager.php index ebeb47e5d4b..4ee3b1b4fac 100644 --- a/library/Zend/Session/SessionManager.php +++ b/library/Zend/Session/SessionManager.php @@ -163,7 +163,7 @@ public function writeClose() // object isImmutable. $storage = $this->getStorage(); if (!$storage->isImmutable()) { - $_SESSION = (array) $storage; + $_SESSION = $storage->toArray(); session_write_close(); $storage->fromArray($_SESSION); $storage->markImmutable(); diff --git a/tests/ZendTest/Session/SessionManagerTest.php b/tests/ZendTest/Session/SessionManagerTest.php index 0714b03fad7..ac23f14ef25 100644 --- a/tests/ZendTest/Session/SessionManagerTest.php +++ b/tests/ZendTest/Session/SessionManagerTest.php @@ -153,6 +153,18 @@ public function testStartDoesNothingWhenCalledAfterWriteCloseOperation() $this->assertEquals($id1, $id2); } + /** + * @runInSeparateProcess + */ + public function testStorageContentIsPreservedByWriteCloseOperation() + { + $this->manager->start(); + $storage = $this->manager->getStorage(); + $storage['foo'] = 'bar'; + $this->manager->writeClose(); + $this->assertTrue(isset($storage['foo']) && $storage['foo'] == 'bar'); + } + /** * @runInSeparateProcess */