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

Commit 0d974d2

Browse files
committed
Merge branch 'hotfix/45'
Close #45
2 parents f5475c4 + b466131 commit 0d974d2

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ All notable changes to this project will be documented in this file, in reverse
2121
- [#51](https://github.com/zendframework/zend-session/pull/51) provides a fix to
2222
the `DbTableGateway` save handler to prevent infinite recursion when
2323
attempting to destroy an expired record during initial read operations.
24+
- [#45](https://github.com/zendframework/zend-session/pull/45) updates the
25+
`SessionManager::regenerateId()` method to only regenerate the identifier if a
26+
session already exists.
2427

2528
## 2.7.2 - 2016-06-24
2629

src/SessionManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ public function getId()
320320
*/
321321
public function regenerateId($deleteOldSession = true)
322322
{
323-
session_regenerate_id((bool) $deleteOldSession);
323+
if ($this->sessionExists()) {
324+
session_regenerate_id((bool) $deleteOldSession);
325+
}
326+
324327
return $this;
325328
}
326329

test/SessionManagerTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,17 @@ public function testRegenerateIdShouldWorkAfterSessionStarted()
433433
$this->assertNotSame($origId, $this->manager->getId());
434434
}
435435

436+
/**
437+
* @runInSeparateProcess
438+
*/
439+
public function testRegenerateIdDoesNothingWhenSessioIsNotStarted()
440+
{
441+
$origId = $this->manager->getId();
442+
$this->manager->regenerateId();
443+
$this->assertEquals($origId, $this->manager->getId());
444+
$this->assertEquals('', $this->manager->getId());
445+
}
446+
436447
/**
437448
* @runInSeparateProcess
438449
*/

0 commit comments

Comments
 (0)