Skip to content

[HttpKernel] trim the leading backslash in the controller init #32541

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

Conversation

Simperfit
Copy link
Contributor

Q A
Branch? 4.4
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #29945
License MIT
Doc PR none

This fixes an error where the classes exists when using a leading backslash in the controller, it's not invalid to do so.

see #30045 (comment)

@Simperfit Simperfit force-pushed the feature/trim-backslash-a-the-start-of-a-controller branch from dce0fc6 to a8ec428 Compare July 15, 2019 06:43
@Simperfit
Copy link
Contributor Author

updated

Status: Needs Review

@fabpot
Copy link
Member

fabpot commented Jul 15, 2019

I would trim only when really needed. What makes trimming neeeded in the first place?

@Simperfit
Copy link
Contributor Author

@fabpot Using a leading backslash will made the `instiateController method fail because it can find the class, according to #30045 (comment), I've update this method to trim when an leading blackslash is passed and to fix this behaviour.

@fabpot
Copy link
Member

fabpot commented Jul 15, 2019

You've changed a method that deals with errors, so this looks suspicious to me.

@Simperfit Simperfit force-pushed the feature/trim-backslash-a-the-start-of-a-controller branch from a8ec428 to 029f653 Compare July 15, 2019 07:23
@Simperfit
Copy link
Contributor Author

Okay I've misread the whole think, was only thinking about the comment, but hey, this is the right fix and I understand why is was deprecated. So maybe the even better fix is to deprecate using backslash like in the first PR that has been closed ;).

WDYT @fabpot ?

@nicolas-grekas nicolas-grekas added this to the next milestone Jul 15, 2019
@fabpot
Copy link
Member

fabpot commented Aug 9, 2019

I think I still don't get the problem. Can you explain it to me again? Perhaps with an example?

@Pierstoval
Copy link
Contributor

IIUC, this PR fixes issues when defining routes like this:

my_route:
    path: /whatever
    controller: \App\Controller\DefaultController

Not sure it's really common, but IMO this should be supported anyway

@fabpot fabpot force-pushed the feature/trim-backslash-a-the-start-of-a-controller branch from 029f653 to 8be6297 Compare August 9, 2019 12:13
@fabpot fabpot changed the base branch from 4.4 to 4.3 August 9, 2019 12:15
@fabpot fabpot force-pushed the feature/trim-backslash-a-the-start-of-a-controller branch from 8be6297 to 3c8d395 Compare August 9, 2019 12:15
@fabpot
Copy link
Member

fabpot commented Aug 9, 2019

Thank you @Simperfit.

@fabpot fabpot merged commit 3c8d395 into symfony:4.3 Aug 9, 2019
fabpot added a commit that referenced this pull request Aug 9, 2019
…init (Simperfit, fabpot)

This PR was submitted for the 4.4 branch but it was merged into the 4.3 branch instead (closes #32541).

Discussion
----------

[HttpKernel] trim the leading backslash in the controller init

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #29945
| License       | MIT
| Doc PR        | none <!-- required for new features -->

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

This fixes an error where the classes exists when using a leading backslash in the controller, it's not invalid to do so.

see #30045 (comment)

Commits
-------

3c8d395 [HttpKernel] fixed class having a leading \ in a route controller
6fdf252 [HttpKernel] trim the leading backslash in the controller init
@Simperfit Simperfit deleted the feature/trim-backslash-a-the-start-of-a-controller branch August 9, 2019 12:16
@fabpot fabpot mentioned this pull request Aug 26, 2019
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants