78b11a591d
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
-------
|
||
---|---|---|
.. | ||
CacheWarmer | ||
Command | ||
Console | ||
Controller | ||
DataCollector | ||
DependencyInjection | ||
EventListener | ||
HttpCache | ||
Kernel | ||
Resources | ||
Routing | ||
Templating | ||
Test | ||
Tests | ||
Translation | ||
Validator | ||
.gitignore | ||
CHANGELOG.md | ||
Client.php | ||
composer.json | ||
FrameworkBundle.php | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md |