[HttpFoundation] Always call proxied handler::destroy() in StrictSessionHandler
This commit is contained in:
parent
f95ac4f809
commit
e5e2d5ddd2
@ -19,6 +19,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
|
|||||||
class StrictSessionHandler extends AbstractSessionHandler
|
class StrictSessionHandler extends AbstractSessionHandler
|
||||||
{
|
{
|
||||||
private $handler;
|
private $handler;
|
||||||
|
private $doDestroy;
|
||||||
|
|
||||||
public function __construct(\SessionHandlerInterface $handler)
|
public function __construct(\SessionHandlerInterface $handler)
|
||||||
{
|
{
|
||||||
@ -63,11 +64,24 @@ class StrictSessionHandler extends AbstractSessionHandler
|
|||||||
return $this->handler->write($sessionId, $data);
|
return $this->handler->write($sessionId, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function destroy($sessionId)
|
||||||
|
{
|
||||||
|
$this->doDestroy = true;
|
||||||
|
$destroyed = parent::destroy($sessionId);
|
||||||
|
|
||||||
|
return $this->doDestroy ? $this->doDestroy($sessionId) : $destroyed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function doDestroy($sessionId)
|
protected function doDestroy($sessionId)
|
||||||
{
|
{
|
||||||
|
$this->doDestroy = false;
|
||||||
|
|
||||||
return $this->handler->destroy($sessionId);
|
return $this->handler->destroy($sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class StrictSessionHandlerTest extends TestCase
|
|||||||
$handler->expects($this->once())->method('read')
|
$handler->expects($this->once())->method('read')
|
||||||
->with('id')->willReturn('');
|
->with('id')->willReturn('');
|
||||||
$handler->expects($this->never())->method('write');
|
$handler->expects($this->never())->method('write');
|
||||||
$handler->expects($this->never())->method('destroy');
|
$handler->expects($this->once())->method('destroy')->willReturn(true);
|
||||||
$proxy = new StrictSessionHandler($handler);
|
$proxy = new StrictSessionHandler($handler);
|
||||||
|
|
||||||
$this->assertFalse($proxy->validateId('id'));
|
$this->assertFalse($proxy->validateId('id'));
|
||||||
@ -154,7 +154,7 @@ class StrictSessionHandlerTest extends TestCase
|
|||||||
$handler = $this->getMockBuilder('SessionHandlerInterface')->getMock();
|
$handler = $this->getMockBuilder('SessionHandlerInterface')->getMock();
|
||||||
$handler->expects($this->once())->method('read')
|
$handler->expects($this->once())->method('read')
|
||||||
->with('id')->willReturn('');
|
->with('id')->willReturn('');
|
||||||
$handler->expects($this->never())->method('destroy');
|
$handler->expects($this->once())->method('destroy')->willReturn(true);
|
||||||
$proxy = new StrictSessionHandler($handler);
|
$proxy = new StrictSessionHandler($handler);
|
||||||
|
|
||||||
$this->assertSame('', $proxy->read('id'));
|
$this->assertSame('', $proxy->read('id'));
|
||||||
|
Reference in New Issue
Block a user