bug #18018 [HttpFoundation] exception when registering bags for started sessions (xabbuh)
This PR was merged into the 2.3 branch.
Discussion
----------
[HttpFoundation] exception when registering bags for started sessions
| Q | A
| ------------- | ---
| Branch | 2.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #10707, #16136
| License | MIT
| Doc PR |
Commits
-------
c4a5b67
exception when registering bags for started sessions
This commit is contained in:
commit
5d8067f32d
@ -260,6 +260,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||
*/
|
||||
public function registerBag(SessionBagInterface $bag)
|
||||
{
|
||||
if ($this->started) {
|
||||
throw new \LogicException('Cannot register a bag when the session is already started.');
|
||||
}
|
||||
|
||||
$this->bags[$bag->getName()] = $bag;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,16 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
|
||||
$storage->getBag('non_existing');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testRegisterBagForAStartedSessionThrowsException()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
$storage->start();
|
||||
$storage->registerBag(new AttributeBag());
|
||||
}
|
||||
|
||||
public function testGetId()
|
||||
{
|
||||
$storage = $this->getStorage();
|
||||
|
Reference in New Issue
Block a user