Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedJan 30, 2019
The PR table looks fine thanks. |
Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
itscaro commentedJan 30, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@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. |
| returnparent::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 notbegin with"\"',$class),E_USER_DEPRECATED); | |
| @trigger_error(sprintf('The controller definition "%s" must notstart witha backslash.',$class),E_USER_DEPRECATED); |
It looks likestart 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.
| try { | ||
| returnparent::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 anotice IMO we should nottrigger only on Excpetion
| returnparent::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 notbegin with"\"',$class),E_USER_DEPRECATED); | |
| @trigger_error(sprintf('The controller definition "%s" must notstart witha backslash.',$class),E_USER_DEPRECATED); |
It looks likestart 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.
| try { | ||
| returnparent::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 theinstantiateController method?
Simperfit commentedJul 3, 2019
fabpot commentedJul 12, 2019
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 <!-- seehttps://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 peopleunderstand your PR and can be used as a start for the documentation.Additionally (seehttps://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 controller6fdf252 [HttpKernel] trim the leading backslash in the controller init
Uh oh!
There was an error while loading.Please reload this page.