[HttpKernel] Fix variadic TypeError for #[MapUploadedFile]#54901
[HttpKernel] Fix variadic TypeError for #[MapUploadedFile]#54901DjordyKoert wants to merge 1 commit into
#[MapUploadedFile]#54901Conversation
#[MapUploadedFile]
|
Failing tests seem unrelated |
| } | ||
|
|
||
| $arguments[$i] = $payload; | ||
| if ($argument->metadata->isVariadic() && \is_array($payload)) { |
There was a problem hiding this comment.
if the payload is not an array, we should throw a 422 instead, don't you think?
we should also use array_is_list so that we don't map to named arguments by mistake
|
|
||
| $arguments[$i] = $payload; | ||
| if ($argument->metadata->isVariadic() && \is_array($payload)) { | ||
| array_splice($arguments, $i, 1, $payload); |
There was a problem hiding this comment.
could we use array_merge instead? that might be more readable
There was a problem hiding this comment.
Seems like the PR is somewhat stale 😞
Unfortunately, array_merge won't work here because the current logic processes the existing $arguments and replaces them one by one. The variadic variable can only be at the end of the function signature, so we need to extend that array further.
Therefore, array_splice is appropriate here.
I have added a bit updated fix to my PR, where I tried to fix another related issue with #[MapUploadedFile]
There was a problem hiding this comment.
@melya I will close this PR then. Thank you :)
This PR fixes a bug introduced in #49978 where using
#[MapUploadedFile]with a variadic argument causes aTypeError:(Bug fix taken from #54817)