-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Implemented FR #51634: Can't post multiple fields with the same name #8292
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
This PR allows for multiple values with the same field name to be sent to an HTTP server. This server can't be PHP, because PHP's POST processing does not allow for two the same field names. But sending multiple fields with the same name is required for some operations by RFC 7578. This PR allows you to attach an array of values to a field name, and each of these will then be sent as its own distinct multipart/form-data field.
] | ||
]; | ||
|
||
$options = array( |
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.
Any reason not to use the short array syntax []
here?
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.
Not really, I probably copied it from the original example. Will fix.
} | ||
#endif | ||
zend_tmp_string_release(tmp_postval); | ||
add_simple_field(mime, string_key, current); |
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.
Nit: An else-case and removing the continue
could remove the duplicate zend_string_release_ex
.
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.
Yes, but IMO the current code is more readable, as each special block now looks the same. If we'd to add one in the future, then it's less likely the wrong thing gets copied. (I'm also allergic to else
).
(I merged this manually) |
Will this fix be backported to all currently supported branches or will it only be in PHP >= 8.2? |
This only targets the master branch (PHP 8.2). A backport might be considered, but feature requests usually don't get backported to stable versions. |
Of course. But as far as I understand the issue, this (c|sh)ould be considered as bug fix and not as a new feature. What do the release managers of PHP 8.0 and PHP 8.1 think about this? |
Wow 12 years almost to the day since I opened that ticket! |
I guess you're not seeing notifications of comments on commits so I'll repost this here: This commit introduces a dependency on curl 7.56.0 @derickr -
|
Fortunately, this has only been merged into the "master" branch; but still this needs to fixed. Currently, "master" requires libcurl ≥ 7.29.0; lifting a bit might be okay, but 7.56.0 (released 2017-10-04) is likely too much |
I don't accept that software released for five years by the time PHP 8.2 comes out is "too new". If distributions bundle that new a version of PHP, then they should also have updated their libcurl. But I should bump the version requirement so that it prevents you from getting a compile error. |
Well, so far our stance was to be rather conservative regarding version requirements of libcurl and other libraries. I think bumping to 7.56.0 should at least be discussed on the internals mailing list. And if we bump, we likely can simplify other parts of ext/curl. |
personally I'm fine with whatever requirement you'd want but I'd noticed the careful coding using |
I second that emotion. |
@SjonHortensius Yes, but it is nearly impossible to still find a place that has that old of a curl version ;-) In any case: #8460 should fix it. |
|
|
||
SingleValue | ||
--------------------------%s | ||
Content-Disposition: form-data; name="multi" |
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.
@derickr Hi! Sorry to bother you. I am trying to do the same request with PHP 8.2.9, which doesn't work as expected. What I get is that names are overwritten. So, from this particular test, the receiver will only get Multi2
value. Shouldn't the name be name="multi[]"
?
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.
No, multi
is correct; but like the feature description states:
This server can't be PHP, because PHP's POST processing does not allow for two[sic] the same field names.
@derickr - Hey! Does this allow us to send multiple files using the same key too, like "file[]" ? I'm using PHP 8.3, but I'm not succeeding in doing this:
Thanks! |
No, this is not (yet) supported. Feel free to file a feature request at https://github.com/php/php-src/issues. |
This PR allows for multiple values with the same field name to be sent to an
HTTP server. This server can't be PHP, because PHP's POST processing does not
allow for two the same field names. But sending multiple fields with the same
name is required for some operations by RFC 7578.
This PR allows you to attach an array of values to a field name, and each of
these will then be sent as its own distinct multipart/form-data field.