Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/3461' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jan 17, 2013
3 parents 10cef2a + 6a22f1e + 5801b5b commit 1c82c93
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion src/Storage/SessionArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,11 @@ protected function setRequestAccessTime($time)
*/
public function toArray()
{
$values = $_SESSION;
if (isset($_SESSION)) {
$values = $_SESSION;
} else {
$values = array();
}
if (isset($values['__ZF'])) {
unset($values['__ZF']);
}
Expand Down
12 changes: 12 additions & 0 deletions test/SessionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 1c82c93

Please sign in to comment.