Commit 2af8f39
committed
bug #50458 [HttpKernel] Fix default value ignored with pinned resolvers (HypeMC)
This PR was merged into the 6.3 branch.
Discussion
----------
[HttpKernel] Fix default value ignored with pinned resolvers
| 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:
```php
#[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.
Commits
-------
fabe7bc [HttpKernel] Fix default value ignored with pinned resolversFile tree
4 files changed
+36
-9
lines changed- src/Symfony/Component/HttpKernel
- Controller
- ArgumentResolver
- Tests/Controller
- ArgumentResolver
4 files changed
+36
-9
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
75 | 78 | | |
76 | 79 | | |
77 | 80 | | |
| |||
Lines changed: 2 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 34 | + | |
| 35 | + | |
40 | 36 | | |
41 | 37 | | |
42 | 38 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
299 | 319 | | |
300 | 320 | | |
301 | 321 | | |
| |||
373 | 393 | | |
374 | 394 | | |
375 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
376 | 404 | | |
377 | 405 | | |
378 | 406 | | |
| |||
0 commit comments