Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c4d09b0

Browse filesBrowse files
[HttpFoundation] Always call proxied handler::destroy() in StrictSessionHandler
1 parent f95ac4f commit c4d09b0
Copy full SHA for c4d09b0

File tree

2 files changed

+24
-2
lines changed
Filter options

2 files changed

+24
-2
lines changed

‎src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
class StrictSessionHandler extends AbstractSessionHandler
2020
{
2121
private $handler;
22+
private $newSessionId;
2223

2324
public function __construct(\SessionHandlerInterface $handler)
2425
{
@@ -39,6 +40,17 @@ public function open($savePath, $sessionName)
3940
return $this->handler->open($savePath, $sessionName);
4041
}
4142

43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public function read($sessionId)
47+
{
48+
$data = parent::read($sessionId);
49+
$this->newSessionId = '' === $data ? $sessionId : null;
50+
51+
return $data;
52+
}
53+
4254
/**
4355
* {@inheritdoc}
4456
*/
@@ -60,9 +72,19 @@ public function updateTimestamp($sessionId, $data)
6072
*/
6173
protected function doWrite($sessionId, $data)
6274
{
75+
$this->newSessionId = null;
76+
6377
return $this->handler->write($sessionId, $data);
6478
}
6579

80+
/**
81+
* {@inheritdoc}
82+
*/
83+
public function destroy($sessionId)
84+
{
85+
return parent::destroy($sessionId) && ($this->newSessionId !== $sessionId || $this->doDestroy($sessionId));
86+
}
87+
6688
/**
6789
* {@inheritdoc}
6890
*/

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testWriteEmptyNewSession()
118118
$handler->expects($this->once())->method('read')
119119
->with('id')->willReturn('');
120120
$handler->expects($this->never())->method('write');
121-
$handler->expects($this->never())->method('destroy');
121+
$handler->expects($this->once())->method('destroy')->willReturn(true);
122122
$proxy = new StrictSessionHandler($handler);
123123

124124
$this->assertFalse($proxy->validateId('id'));
@@ -154,7 +154,7 @@ public function testDestroyNewSession()
154154
$handler = $this->getMockBuilder('SessionHandlerInterface')->getMock();
155155
$handler->expects($this->once())->method('read')
156156
->with('id')->willReturn('');
157-
$handler->expects($this->never())->method('destroy');
157+
$handler->expects($this->once())->method('destroy')->willReturn(true);
158158
$proxy = new StrictSessionHandler($handler);
159159

160160
$this->assertSame('', $proxy->read('id'));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.