-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Form field values with integer keys not resolved correctly #47505
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 |
The appveyor failed test seems so unrelated... |
Regarding the appveyor feature, I see is failing in may other PRs and in 6.2 HEAD as well |
@claudiu-cristea The problem with this approach is that it undoes the original PRs intentions. I've created an alternative PR which tries to solve the problem in the |
@HypeMC Thank you for following on this.
Could you, please, elaborate, what exactly is undoing? Could you give an example of valid data part(s) that is no more possible with this MR? I think having two distinct I'm gonna take a look at #47618 |
@claudiu-cristea Actually, it depends on how the application you are browsing works. In the past, I have worked with some apis that support having the same form filed multiple times with different values, or even the same query string param multiple times. An example of a valid data part that doesn't work any more: $parts[] = $p14 = clone $p1;
- $p14->setName('quuz2[corge]');
+ $p14->setName('quuz2[0][corge]');
$parts[] = $p15 = clone $p1;
- $p15->setName('quuz2[corge]');
+ $p15->setName('quuz2[1][corge]'); |
@HypeMC thank you. I was looking to RFC 2388, section 3. Definition of multipart/form-data, where it states:
This seems to me an application of the broader concept of multipart MIME data streams, where multiple parts with the same name are allowed. But in this class it's about form data, right? So, I think, we should follow RFC 2388. I did a very simple test with a form: <form method="post" enctype="multipart/form-data" action="a.php">
<input type="hidden" name="foo[0]" value="1">
<input type="hidden" name="foo[0]" value="2">
<input type="submit">
</form> and <?php
print_r($_POST); Submitting this form it shows:
Meaning, in a form, fields with the same name are overriding the previous one. However, looking to the POST request's, I see:
But here's about forms, right? |
I stumbled upon this PR after encountering many |
@nicrodgers unfortunately it seems there’s no interest in this issue even it’s a very clear bug. I’ve ended up by using BrowserKit with Guzzle as client. I wonder how it was possible to merge #38323 with such an assumption |
d92dfef
to
923de03
Compare
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.
I've updated the PR to keep support for duplicate keys but only at the root level. The convention is that if at the root level a key is an integer, then we enforce a [$key => $value]
structure. This allows building any form with any repeated keys, with one exception: it's not possible to use integers as root-level keys. I think this limitation is not a limiting one in practice.
This changes the behavior introduced in #38323, which was way too disruptive, and unneeded to achieve the target goal.
Thank you @claudiu-cristea. |
This should be legit:
Fixes #47504