Skip to content
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

[HttpKernel] Fix default value ignored with pinned resolvers #50458

Merged
merged 1 commit into from May 29, 2023

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented May 28, 2023

Q A
Branch? 6.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Since #48992 the default value is ignored when, for example, #[MapEntity] is used:

#[Route('/')]
#[Route('/{someId}')]
public function index(#[MapEntity(id: 'someId')] ?Post $post): Response
{
    // ...
}

Before, $post would be null when making a request to /, now an exception is thrown:

Controller "App\Controller\TestController::index" requires that you provide a value for the "$post" argument.
Either the argument is nullable and no null value has been provided,
no default value has been provided or there is a non-optional argument after this one.

Since I can't think of a valid case when one would want to ignore the default value, I'd suggest always adding the DefaultValueResolver to the list when a pinned resolver is used.

@nicolas-grekas
Copy link
Member

Can you please revert #50340 in the patch also please? Your approach makes it unneeded.

@HypeMC
Copy link
Contributor Author

HypeMC commented May 29, 2023

Can you please revert #50340 in the patch also please? Your approach makes it unneeded.

Done

@nicolas-grekas
Copy link
Member

Thank you @HypeMC.

@nicolas-grekas nicolas-grekas merged commit 2af8f39 into symfony:6.3 May 29, 2023
6 of 9 checks passed
@HypeMC HypeMC deleted the default-value-resolver branch May 29, 2023 13:37
@fabpot fabpot mentioned this pull request May 30, 2023
fabpot added a commit that referenced this pull request Dec 17, 2023
…ed resolvers (HypeMC)

This PR was merged into the 6.3 branch.

Discussion
----------

[HttpKernel] Fix request attribute value ignored with pinned resolvers

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #52875
| License       | MIT

This is similar to #50458. When pinned resolvers are used, values already resolved in the request attributes bag are ignored.

Commits
-------

dd725be [HttpKernel] Fix request attribute value ignored with pinned resolvers
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.

None yet

3 participants