-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Session][Test] MockFileSessionStorage is not persistent #22616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I cannot reproduce this problem on Symfony 2.8 😋 Can you fork the symfony standard edition and apply the minimal changes to reproduce this issue? |
@dmaicher 2.8: https://github.com/swordbeta/symfony-standard/commit/32e300b108ba476f3daed2efee7852d940546df8 Tested on 3 different machines with 7.1.3 and 7.1.4 |
ok thanks 👍 I think the difference to my tests was that I tested it behind a firewall 😋 Seems weird indeed the behaviour. This works: /**
* @Route("/", name="homepage")
*/
public function indexAction()
{
$this->get('session')->set('test', 'test');
return new Response('All good');
} And this also: /**
* @Route("/", name="homepage")
*/
public function indexAction()
{
$this->get('session')->set('test', 'test');
$this->get('session')->save();
$this->get('session')->start();
return new Response('All good');
} |
@dmaicher weird that the first one works, isn't save always called at the end? I guess I could just remove the save call for now |
Looks like this is some how expected https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php#L104, maybe a documentation issue? |
You shouldn't be calling |
This looks like a bug. The NativeSessionStorage does not throw an exception when saving twice. A |
Well, the logic was deliberately introduced in #6362 |
Investigating this again as part of the I cannot reproduce this anymore on Symfony 3.4+. Also with recent changes in |
I still think it should not throw an exception in symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php Line 91 in a84842b
return; . But since the original issue is not reproducible and save is not called anymore when the session has not been started, there is no point in changing the mock storage and potentially add a bc break.
|
The following controller:
Used in a test:
Expected: Test succeeds. Session is persisted as documented here.
Actual: Test fails. The session is not persisted through the two requests.
The following line causes this:
symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php
Line 104 in 85e2d2f
Another 'solution' is adding the following line to the first action:
Adding this get after the save sets the
started
variable back totrue
meaning the session is persisted, which is rather odd and made debugging this issue very frustrating.The text was updated successfully, but these errors were encountered: