-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[BrowserKit] Merge fields and files recursively if they are multidimensional array #40828
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
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
de8deeb
to
e1fd353
Compare
fca9943
to
710a440
Compare
Hey! I think @azhurb has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
@@ -82,7 +82,11 @@ private function getBodyAndExtraHeaders(Request $request, array $headers): array | |||
$fields = $request->getParameters(); | |||
|
|||
if ($uploadedFiles = $this->getUploadedFiles($request->getFiles())) { | |||
$part = new FormDataPart(array_merge($fields, $uploadedFiles)); | |||
if (\count($fields) !== \count($fields, \COUNT_RECURSIVE)) { | |||
$part = new FormDataPart(array_merge_recursive($fields, $uploadedFiles)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be careful about array_merge_recursive
. It can do weird things in case of associative arrays. See https://friendsofsymfony.github.io/slides/config_definition.html#6 (and the next slide showing the result). Slides were in French, but the code snippets should still be understandable without the comments anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof alright, I changed it to array_replace_recursive
instead
Thank you @januszmk. |
2f22d7e
to
66c3415
Compare
if we have a form that is prefixed, with form fields like: text:
foo[name]
, file:foo[file]
, request is loosing non-files fields. encountered this issue while submittingSymfony\Component\DomCrawler\Form
in tests