This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Bundle/FrameworkBundle
Fabien Potencier 78b11a591d bug #36063 [FrameworkBundle] start session on flashbag injection (William Arslett)
This PR was squashed before being merged into the 3.4 branch.

Discussion
----------

[FrameworkBundle] start session on flashbag injection

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix [#33084](https://github.com/symfony/symfony/issues/33084)
| License       | MIT

This PR addresses an issue whereby if the FlashBag is injected into the application using the default service configuration, we cannot rely that the session has been started. This behaviour is in contradiction to [the docs](https://symfony.com/doc/current/session.html#avoid-starting-sessions-for-anonymous-users):

> Sessions are automatically started whenever you read, write or even check for the existence of data in the session.

This is because symfony ensures the session has been started on calls to getFlashBag() which is normally how the flashbag will be accessed but this is not called if you inject the FlashBag directly into the container.

I have addressed this issue by changing the way the Flashbag service is built so that it uses Session as a factory service and getFlashBag as a factory method. This means that anywhere in symfony where FlashBag is injected can now rely on the fact the session is started.

I have also added a new functional test to verify this behaviour.

Commits
-------

e8b4d35616 [FrameworkBundle] start session on flashbag injection
2020-03-16 07:35:10 +01:00
..
CacheWarmer Remove superfluous phpdoc tags 2019-08-14 13:59:53 +02:00
Command Add missing dots at the end of exception messages 2020-03-15 10:38:08 +01:00
Console [FrameworkBundle] remove redundant PHPDoc in console Descriptor and subclass 2020-03-09 19:12:25 +01:00
Controller Check non-null type for numeric type 2020-01-02 00:53:08 +03:30
DataCollector switched array() to [] 2019-01-16 10:39:14 +01:00
DependencyInjection Add missing dots at the end of exception messages 2020-03-15 10:38:08 +01:00
EventListener Fix inconsistent return points. 2019-08-20 15:31:17 +02:00
HttpCache Avoid stale-if-error if kernel.debug = true, because it hides errors 2020-01-10 10:52:55 +00:00
Kernel Remove superfluous phpdoc tags 2019-08-14 13:59:53 +02:00
Resources [FrameworkBundle] start session on flashbag injection 2020-03-16 07:35:04 +01:00
Routing [FrameworkBundle] Detect indirect env vars in routing 2019-08-05 07:22:32 +02:00
Templating Add missing dots at the end of exception messages 2020-03-15 10:38:08 +01:00
Test Add missing dots at the end of exception messages 2020-03-15 10:38:08 +01:00
Tests [FrameworkBundle] start session on flashbag injection 2020-03-16 07:35:04 +01:00
Translation switched array() to [] 2019-01-16 10:39:14 +01:00
Validator switched array() to [] 2019-01-16 10:39:14 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md Fixed markdown file 2019-08-13 19:39:09 +02:00
Client.php [FrameworkBundle] Fix calling Client::getProfile() before sending a request 2019-06-25 17:43:39 +02:00
composer.json [FrameworkBundle] fix fix fix deps=low 2020-02-07 10:13:59 +01:00
FrameworkBundle.php add constraint validators before optimizations 2019-02-06 11:00:25 +01:00
LICENSE Update year in license files 2020-01-01 12:03:25 +01:00
phpunit.xml.dist Merge branch '2.8' into 3.4 2018-11-11 20:48:54 +01:00
README.md add readme files where missing 2016-03-07 11:36:15 +01:00