-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Raise notice when controller is defined with a starting back slash #30045
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
d466e61
to
9f33bd2
Compare
The PR table looks fine thanks. |
Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
af1fcff
to
2ea10b4
Compare
@nicolas-grekas like this? I put it in catch so that it will not be evaluated each time, but maybe it's preferable to put it at the start of the function? about the services, if the controller is defined with Implementing only the notice for controller declaration seem insufficient and might make confusion too. |
@@ -54,6 +54,9 @@ protected function instantiateController($class) | |||
try { | |||
return parent::instantiateController($class); | |||
} catch (\Error $e) { | |||
if (0 === strpos($class, '\\')) { | |||
@trigger_error(sprintf('The controller definition "%s" must not begin with "\"', $class), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe: must not start with a slash
Instead of
“\” ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH it's backslash actually ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @OskarStark and you. What about
@trigger_error(sprintf('The controller definition "%s" must not begin with "\"', $class), E_USER_DEPRECATED); | |
@trigger_error(sprintf('The controller definition "%s" must not start with a backslash.', $class), E_USER_DEPRECATED); |
It looks like start with smth
is the correct wording: https://www.thefreedictionary.com/words-that-start-with-x .
We should also add a dot, because it's a sentence.
@@ -54,6 +54,9 @@ protected function instantiateController($class) | |||
try { | |||
return parent::instantiateController($class); | |||
} catch (\Error $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a notice
IMO we should not trigger
only on Excpetion
@@ -54,6 +54,9 @@ protected function instantiateController($class) | |||
try { | |||
return parent::instantiateController($class); | |||
} catch (\Error $e) { | |||
if (0 === strpos($class, '\\')) { | |||
@trigger_error(sprintf('The controller definition "%s" must not begin with "\"', $class), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @OskarStark and you. What about
@trigger_error(sprintf('The controller definition "%s" must not begin with "\"', $class), E_USER_DEPRECATED); | |
@trigger_error(sprintf('The controller definition "%s" must not start with a backslash.', $class), E_USER_DEPRECATED); |
It looks like start with smth
is the correct wording: https://www.thefreedictionary.com/words-that-start-with-x .
We should also add a dot, because it's a sentence.
@@ -54,6 +54,9 @@ protected function instantiateController($class) | |||
try { | |||
return parent::instantiateController($class); | |||
} catch (\Error $e) { | |||
if (0 === strpos($class, '\\')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deprecating this possibility, what about trimming the starting backslash in the instantiateController
method?
Closing as there is no more feedback and I think the approach is not the right one. |
…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
Uh oh!
There was an error while loading. Please reload this page.