Closed
<
759C
a class="Avatar-module__avatarLink--S36bm Avatar-module__avatarOuter--MZJZH prc-Link-Link-85e08" href="https://github.com/MacDada" data-hovercard-url="/users/MacDada/hovercard" aria-label="@MacDada's profile">
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 2.7+ |
https://github.com/symfony/http-foundation/blob/2.7/Session/Storage/MockArraySessionStorage.php#L175
clear()
iterates over list of bags, but… sometimes there are no bags and it results in PHP error:
Invalid argument supplied for foreach()
How to get that error?
$storage = new MockArraySessionStorage();
$storage->clear();
I stumbled upon this then I was writing a test to reproduce #7104:
public function testLogout(Client $client)
{
$client->getKernel()->boot();
$client->getContainer()->get('session.storage.filesystem')->clear();
$client->request('GET', '/logout');
Possible solutions:
- a.) Throw exception instead of having PHP error (message could say what's wrong).
- b.) Return early when
$this->bags
isnull
. - c.) Always keep
$this->bags
as array (instead of possiblenull
).
b
and c
could be considered BC if someone relied upon this "not working" (but I'd say the chances are low).
After it is decided what to do with this issue, I can create PR with test and implementation.