Skip to content

[Routing][4.1][BC Break] Controller names drop single colon notation #27522

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

Closed
Majkl578 opened this issue Jun 6, 2018 · 5 comments
Closed

[Routing][4.1][BC Break] Controller names drop single colon notation #27522

Majkl578 opened this issue Jun 6, 2018 · 5 comments

Comments

@Majkl578
Copy link
Contributor

Majkl578 commented Jun 6, 2018

Symfony version(s) affected: 4.1.0

Description
Route loader (DelegatingLoader) now always returns controllers with double-colon notation.
This breaks existing code that relies on the single-colon format.

How to reproduce
Have a controller referenced with single colons. Although the code affected is a custom route loader that generates such controller names, it shouldn't be directly needed to have one to reproduce.

Possible Solution
Revert the change for implicitly changing : to :::

$controller = str_replace(':', '::', $controller);

as commented here

Suggesting to keep the deprecation, but revert forced change from : to ::.

Additional context
The code affected performs different logic based on whether controller is single-colon or double-colon notation (in the _controller request attribute). Single colon is used for a controller that is registered as a DI service, double colon is used for non-registered controllers.
Although possibly unfortunate (dates back to SF 2.6), this has been working flawlessly until SF 4.1.

Introduced in #26085.

@stof
Copy link
Member

stof commented Jun 6, 2018

Single colon is used for a controller that is registered as a DI service, double colon is used for non-registered controllers.

but that detection is already wrong in 3.4 and 4.0: if your service is registered as a service using its FQCN as id, you could already use the double colon in 3.4 and 4.0, but the service would still be used.
so the custom logic relying on the fact that anything using double colon would not be a service was already not working on older 3.4 and 4.0.

thus, if we consider this change a BC break, it would also mean that we can never add any new feature in the controller syntax, as any logic assuming the old rules would break when using the new feature.

@Tobion
Copy link
Contributor

Tobion commented Jun 6, 2018

The code affected performs different logic based on whether controller is single-colon or double-colon notation (in the _controller request attribute). Single colon is used for a controller that is registered as a DI service, double colon is used for non-registered controllers.

This is not a safe assumption. Even since SF 3.3, double colon could be used for controllers as services under some circumstances. This is why we deprecated the single column syntax.
Considering this, you need to change your logic anyway to make it work properly.

@Majkl578
Copy link
Contributor Author

Majkl578 commented Jun 6, 2018

so the custom logic relying on the fact that anything using double colon would not be a service was already not working on older 3.4 and 4.0

As you can see, it was working perfectly fine until 4.1.0. Maybe because no other bundles (Rest, Twig etc.) were used, but it was working flawlessly.

it would also mean that we can never add any new feature in the controller syntax

Well you can, in major version for sure. But breaking bundles in minor versions is unfortunate.

This is not a safe assumption.

Agreed, as I said, this is coming from days of SF 2.6.

This is why we deprecated the single column syntax.

I totally agree with that, it has always been confusing.

Considering this, you need to change your logic anyway to make it work properly.

Yes: 4.x should throw deprecation (as it does), but it should still work until 5.0, otherise the BC promise is broken. :/

@nicolas-grekas
Copy link
Member

Anyone willing to try a fix?

@dmaicher
Copy link
Contributor

dmaicher commented Jun 9, 2018

See #27566

fabpot added a commit that referenced this issue Jun 11, 2018
… notation (dmaicher)

This PR was merged into the 4.1 branch.

Discussion
----------

[FrameworkBundle] fix for allowing single colon controller notation

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

This fixes a BC break introduced in #26085 (review).

ping @Tobion

Commits
-------

1680674 [FrameworkBundle] fix for allowing single colon controller notation
@fabpot fabpot closed this as completed Jun 11, 2018
iteman added a commit to iteman/pageflower-bundle that referenced this issue Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants