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
Fabien Potencier f0519486f2 bug #23013 Parse the _controller format in sub-requests (weaverryan)
This PR was merged into the 3.3 branch.

Discussion
----------

Parse the _controller format in sub-requests

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | possibly (edge case)
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22966
| License       | MIT
| Doc PR        | n/a

As mentioned on the issue (https://github.com/symfony/symfony/issues/22966#issuecomment-305289227), the new "controller service args" functionality relies on the `_controller` attribute to be in either the service format `App\Controller\Foo:bar` or at least the final parsed format `App\Controller\Foo::bar`. But when you make a sub-request with the `App:Foo:bar` format, the `ControllerResolver` correctly parses this, but the `_controller` request attribute will always contain the original `App:Foo:bar` format. That causes the `ServiceValueResolver` to fail.

The only way I can think to fix this - reliably - is to parse the `_controller` attribute in a listener. And this, works great! Notes:

A) There is a small chance for a BC break: if you were relying on the `_controller` old format in a `kernel.request` format in the framework, in a listener between the priority of 25 and 31 for sub-requests (because normal requests have `_controller` normalized during routing)... then you will see a behavior change.

B) We could load the `ControllerNameParser` lazily via a service locator.

C) We could deprecate calling the parser in the FW's `ControllerResolver`. Along with (B), I think it would (in 4.0) mean that the `ControllerNameParser` is not instantiated at runtime (except for sub-requests).

If someone can think of a different/better solution, please let me know!

Cheers!

Commits
-------

9578fd3eb6 Adding a new event subscriber that "parses" the _controller attribute in the FW
2017-06-02 14:53:18 -07:00
..
DebugBundle [DI] Defaults to public=false in all service config files 2017-05-03 19:24:51 +02:00
FrameworkBundle bug #23013 Parse the _controller format in sub-requests (weaverryan) 2017-06-02 14:53:18 -07:00
SecurityBundle Fix composer deps 2017-06-02 14:59:20 +02:00
TwigBundle Merge branch '3.2' into 3.3 2017-06-02 11:51:43 +02:00
WebProfilerBundle Merge branch '3.2' into 3.3 2017-06-02 10:55:39 +02:00
WebServerBundle [WebServerBundle] Mark ServerCommand as internal 2017-05-23 11:11:47 +02:00
FullStack.php [FrameworkBundle] changed some default configs from canBeEnabled to canBeDisabled 2017-01-07 14:17:04 -08:00