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

[HttpKernel] fix using Target attribute with controller arguments#45572

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

Merged
nicolas-grekas merged 1 commit intosymfony:5.4fromkbond:controller-target-param
Mar 7, 2022

Conversation

@kbond
Copy link
Member

@kbondkbond commentedFeb 27, 2022
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#45021
LicenseMIT
Doc PRn/a

This was supposed tofix#45021 but after adding what I suspected was a failing test, it works as expected. I guess I'm not testing the correct thing?

Here's a quick reproducer that shows the problem in a "real app":

class HomepageControllerextends AbstractController{publicfunction__construct(#[Target('request.logger')]privateLoggerInterface$logger)    {    }    #[Route('/', name:'app_homepage')]publicfunctionindex(#[Target('request.logger')]LoggerInterface$logger):Response    {dd($this->logger->getName(),// "request" (expected)$logger->getName()// "app" (not-expected)        );// ...    }}

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedMar 6, 2022
edited
Loading

The issue happens where there are no bindings, but only a named autowiring alias.
This "else" block should look for aTarget attribute:

}else {
$target =ltrim($target,'\\');
$args[$p->name] =$type ?newTypedReference($target,$type,$invalidBehavior,$p->name) :newReference($target,$invalidBehavior);
}

Please target 5.4 as this is a bugfix IMHO.

@kbondkbondforce-pushed thecontroller-target-param branch 2 times, most recently from66d2268 to164aafcCompareMarch 7, 2022 13:26
@kbondkbond changed the base branch from6.1 to5.4March 7, 2022 13:26
@kbondkbond modified the milestones:6.1,5.4Mar 7, 2022
@kbondkbondforce-pushed thecontroller-target-param branch from164aafc to448cc3aCompareMarch 7, 2022 13:28
@kbond
Copy link
MemberAuthor

I've changed to a 5.4 bug fix. Please confirm the test is done correctly.

@nicolas-grekas
Copy link
Member

Thank you@kbond.

@nicolas-grekasnicolas-grekas merged commit2aa63d1 intosymfony:5.4Mar 7, 2022
@nicolas-grekasnicolas-grekas added Bug and removed Feature labelsMar 7, 2022
@kbondkbond deleted the controller-target-param branchMarch 7, 2022 15:32
This was referencedApr 2, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

[DependencyInjection]Target parameter attribute does not work for controller methods

3 participants

@kbond@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp