Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Commit77289b9
committed
bug#21333 [HttpKernel] Fix ArgumentValueResolver for arguments default null (chalasr)
This PR was merged into the 2.7 branch.Discussion----------[HttpKernel] Fix ArgumentValueResolver for arguments default null| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | n/a| License | MIT| Doc PR | n/aIf an argument has `null` as default value __and annotations are used for routing__, then it is not resolved by the ArgumentResolver e.g:```phppublic function showAction(Request $request) { dump($request); // Request object}public function showAction(?Request $request) { dump($request); // Request object}public function showAction(Request $request = null) { dump($request); // null}```To me, the last example should have been a Request object too.Note that it is the same behavior when using `UserInterface` or whatever, I ran into this issue while trying to dump a user for a route accepting both anonymous and authenticated requests, the argument was always null while `$this->getUser()` returned the expected value. According tohttp://symfony.com/blog/new-in-symfony-3-2-user-value-resolver-for-controllers it should have worked through the argument.I propose to make it works as a bugfix.Any suggestion for improving the patch will be really welcomed. ping@iltarCommits-------d3fa8a1 Avoid setting request attributes from signature arguments in AnnotationClassLoaderFile tree
2 files changed
+3
-9
lines changed- src/Symfony/Component/Routing
- Loader
- Tests/Loader
2 files changed
+3
-9
lines changedLines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | 141 | | |
147 | 142 | | |
148 | 143 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | 139 | | |
141 | | - | |
142 | | - | |
143 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
| |||
0 commit comments
Comments
(0)