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

Appearance settings

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

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

Merged
merged 1 commit into from
May 29, 2023

Conversation

HypeMC
Copy link
Member

@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 HypeMC force-pushed the default-value-resolver branch from bb776bf to f5ea04b Compare May 29, 2023 13:17
@HypeMC
Copy link
Member Author

HypeMC commented May 29, 2023

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

Done

@HypeMC HypeMC force-pushed the default-value-resolver branch from f5ea04b to fabe7bc Compare May 29, 2023 13:25
@nicolas-grekas
Copy link
Member

Thank you @HypeMC.

@nicolas-grekas nicolas-grekas merged commit 2af8f39 into symfony:6.3 May 29, 2023
@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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.