Commit c70be09
committed
bug #46199 [HttpKernel] Handle previously converted
This PR was merged into the 6.1 branch.
Discussion
----------
[HttpKernel] Handle previously converted `DateTime` arguments
| Q | A
| ------------- | ---
| Branch? | 6.1
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix sensiolabs/SensioFrameworkExtraBundle#770
| License | MIT
| Doc PR | N/A
I'm not sure I like this fix, but given the order of operations between the param converters in SensioFrameworkExtraBundle and the controller argument resolvers in the HttpKernel component, this is probably going to cause the least number of headaches for users when upgrading. And in some ways, this is the same problem as #40333 but in reverse.
Because the param converters are triggered on the `kernel.controller` event, they will handle converting values before the controller argument resolvers are fired. This means that a typehinted `DateTimeInterface` will potentially be handled twice (once by the param converter, once by the argument resolver). To avoid the `TypeError` noted in the issue, a practical fix is to gracefully handle a previously converted value in this resolver. As the other options aren't great (removing services from the container or turning off the param converters in full, which has other side effects), this is probably the most practical fix.
Commits
-------
a48ecb6 Handle previously converted DateTime argumentsDateTime arguments (mbabker)File tree
2 files changed
+21
-0
lines changed- src/Symfony/Component/HttpKernel
- Controller/ArgumentResolver
- Tests/Controller/ArgumentResolver
2 files changed
+21
-0
lines changedLines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
116 | 131 | | |
117 | 132 | | |
118 | 133 | | |
| |||
0 commit comments