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/Component/HttpKernel/Tests
Fabien Potencier f62a6d7e88 feature #26681 Allow to easily ask Symfony not to set a response to private automatically (Toflar)
This PR was squashed before being merged into the 4.1-dev branch (closes #26681).

Discussion
----------

Allow to easily ask Symfony not to set a response to private automatically

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This PR is related to the many discussions going on about the latest (Symfony 3.4+) changes regarding the way Symfony handles the session. I think we're almost there now, Symfony 4.1 automatically turns responses into `private` responses once the session is started and it's all done in the `AbstractSessionListener` where the session is also saved.
In other issues/PRs (https://github.com/symfony/symfony/pull/25583, https://github.com/symfony/symfony/pull/25699, https://github.com/symfony/symfony/issues/24988) it was agreed that setting the response to `private` if the session is started is a good default for Symfony. It was also agreed that setting it to `private` does not always make sense because you **can share a response** across sessions, it just requires a more complex caching setup with shared user context etc.
So there must be an easy way to disable this behaviour. Right now it's very hard to do so because what you end up doing is basically decorating the `session_listener` which is very hard because you have to keep track on that over different Symfony versions as the base listener might get additional features etc.

The [FOSCacheBundle](https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/pull/438) is already having this problem, [Contao](https://github.com/contao/core-bundle/pull/1388) has the same issue and there will be probably more. Basically everyone that wants to share a response cache across the session will have to decorate the default listener. That's just too hard, so I came up with this solution. The header is easy. Every project can add that easily. It does not require any extension, configuration or adjustment of any service. It's clean, transparent and has absolutely no impact on "default" Symfony setups.

Would be happy to have some feedback before 4.1 freeze.

Commits
-------

0f36710708 Allow to easily ask Symfony not to set a response to private automatically
2018-03-30 10:02:28 +02:00
..
Bundle [HttpKernel] Remove convention based commands registration 2017-08-10 19:24:31 +02:00
CacheClearer Merge branch '3.3' into 3.4 2017-12-31 07:07:31 +01:00
CacheWarmer Merge branch '3.4' 2017-09-29 11:39:35 +02:00
Config [HttpKernel] Dont register env parameter resource 2017-09-05 09:06:08 +02:00
Controller [HttpKernel] Fix BC of the test suite 2018-02-22 11:30:42 +01:00
ControllerMetadata Remove PHP < 7.1.3 code 2017-05-22 08:50:05 +02:00
DataCollector [VarDumper] Some tweaks after Nicolas' commit & ServerDumperPlaceholderCommand 2018-03-23 10:12:13 +01:00
Debug Updated PHPUnit namespaces 2017-02-20 14:34:33 +01:00
DependencyInjection feature #26627 [DI] Add runtime service exceptions to improve the error message when controller arguments cannot be injected (nicolas-grekas) 2018-03-28 20:04:39 +02:00
Event [HttpKernel] add a test for FilterControllerEvents 2017-11-20 17:56:59 +01:00
EventListener Allow to easily ask Symfony not to set a response to private automatically 2018-03-30 10:02:23 +02:00
Exception [HttpKernel] minor: add ability to construct with headers on http exceptions 2017-04-15 01:12:38 +01:00
Fixtures Display orphaned events in profiler 2018-01-19 08:23:12 +01:00
Fragment Merge branch '3.4' into 4.0 2017-11-30 16:11:43 +01:00
HttpCache Merge branch '2.8' into 3.3 2017-12-12 12:20:26 +01:00
Log [HttpKernel][FrameworkBundle] Add a minimalist default PSR-3 logger 2017-09-29 09:59:44 -07:00
Profiler Improve assertions 2018-02-01 04:11:27 -02:00
ClientTest.php [HttpKernel] fix FC 2018-02-04 18:41:24 +01:00
HttpKernelTest.php [HttpKernel] remove deprecated features 2017-05-24 12:23:11 +02:00
KernelTest.php Merge branch '3.4' into 4.0 2018-02-04 14:08:26 +01:00
Logger.php [2.7] Fix unsilenced deprecation notices 2015-06-16 15:26:24 +02:00
TestHttpKernel.php Added an ArgumentResolver with clean extension point 2016-04-01 11:46:27 +02:00
UriSignerTest.php Merge branch '2.8' into 3.3 2017-12-12 12:20:26 +01:00