8000 [HttpFoundation] Always call proxied handler::destroy() in StrictSess… · symfony/symfony@e5e2d5d · GitHub
[go: up one dir, main page]

Skip to content

Commit e5e2d5d

Browse files
[HttpFoundation] Always call proxied handler::destroy() in StrictSessionHandler
1 parent f95ac4f commit e5e2d5d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 14 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 $doDestroy;
2223

2324
public function __construct(\SessionHandlerInterface $handler)
2425
{
@@ -63,11 +64,24 @@ protected function doWrite($sessionId, $data)
6364
return $this->handler->write($sessionId, $data);
6465
}
6566

67+
/**
68+
* {@inheritdoc}
69+
*/
70+
public function destroy($sessionId)
71+
{
72+
$this->doDestroy = true;
73+
$destroyed = parent::destroy($sessionId);
74+
75+
return $this->doDestroy ? $this->doDestroy($sessionId) : $destroyed;
76+
}
77+
6678
/**
6779
* {@inheritdoc}
6880
*/
6981
protected function doDestroy($sessionId)
7082
{
83+
$this->doDestroy = false;
84+
7185
return $this->handler->destroy($sessionId);
7286
}
7387

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

Lines 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