Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
itscaro wants to merge1 commit intosymfony:masterfromitscaro:quan/issue-29945

Conversation

@itscaro
Copy link

@itscaroitscaro commentedJan 30, 2019
edited
Loading

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets#29945
LicenseMIT
Doc PR

TomasVotruba reacted with thumbs up emoji
@itscaroitscaro deleted the quan/issue-29945 branchJanuary 30, 2019 16:31
@itscaroitscaro changed the titleRaise deprecation notice when the service id starts with \wrong oneJan 30, 2019
@itscaroitscaro reopened thisJan 30, 2019
@itscaroitscaro changed the titlewrong oneRaise notice when controller or service is defined with a starting back slashJan 30, 2019
@nicolas-grekasnicolas-grekas added this to thenext milestoneJan 30, 2019
@nicolas-grekas
Copy link
Member

The PR table looks fine thanks.
But I don't think we should deprecate services starting with a\ - at least that wouldn't help the linked issue at all.
And I also don't think we should hardcode the_controller key in the routing component.
ControllerResolver look like a better place to achieve what is described in#29945

Signed-off-by: Minh-Quan TRAN <account@itscaro.me>
@itscaro
Copy link
Author

itscaro commentedJan 30, 2019
edited
Loading

@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\, the service must be with\ so that the$this->container->has() can find the service. That why in the linked issue I propose to raise notice when controller or service is define with\, so that the only good naming is without starting\.

Implementing only the notice for controller declaration seem insufficient and might make confusion too.

@itscaroitscaro changed the titleRaise notice when controller or service is defined with a starting back slashRaise notice when controller is defined with a starting back slashJan 30, 2019
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);
Copy link
Contributor

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

“\” ?

Copy link
Contributor

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 ;)

Copy link
Contributor

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

Suggested change
@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.

OskarStark reacted with thumbs up emoji

try {
returnparent::instantiateController($class);
}catch (\Error$e) {
Copy link
Contributor

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);
Copy link
Contributor

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

Suggested change
@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.

OskarStark reacted with thumbs up emoji
try {
returnparent::instantiateController($class);
}catch (\Error$e) {
if (0 ===strpos($class,'\\')) {
Copy link
Member

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
Copy link
Contributor

@itscaro Doyou have time to finish this one with what@fabpot suggested ?

@fabpot
Copy link
Member

Closing as there is no more feedback and I think the approach is not the right one.

@fabpotfabpot closed thisJul 12, 2019
fabpot added a commit that referenced this pull requestAug 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     <!-- 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
@nicolas-grekasnicolas-grekas removed this from thenext milestoneOct 27, 2019
@nicolas-grekasnicolas-grekas added this to the4.4 milestoneOct 27, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@fabpotfabpotfabpot requested changes

+3 more reviewers

@eXtremeeXtremeeXtreme left review comments

@ismail1432ismail1432ismail1432 left review comments

@vudaltsovvudaltsovvudaltsov requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

9 participants

@itscaro@nicolas-grekas@Simperfit@fabpot@eXtreme@OskarStark@vudaltsov@ismail1432@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp