Skip to content

Commit 4ca5b35

Browse files
committed
Use ARRAY_OR_OBJECT arg in http_build_query
Instead of checking the type manually. Peculiarily the zpp message does not use "array or object", but that's a general issue. And I guess it's good that object support is not being advertised.
1 parent 900ee57 commit 4ca5b35

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

ext/standard/http.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,13 @@ PHP_FUNCTION(http_build_query)
232232
zend_long enc_type = PHP_QUERY_RFC1738;
233233

234234
ZEND_PARSE_PARAMETERS_START(1, 4)
235-
Z_PARAM_ZVAL(formdata)
235+
Z_PARAM_ARRAY_OR_OBJECT(formdata)
236236
Z_PARAM_OPTIONAL
237237
Z_PARAM_STRING(prefix, prefix_len)
238238
Z_PARAM_STRING(arg_sep, arg_sep_len)
239239
Z_PARAM_LONG(enc_type)
240240
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
241241

242-
if (Z_TYPE_P(formdata) != IS_ARRAY && Z_TYPE_P(formdata) != IS_OBJECT) {
243-
php_error_docref(NULL, E_WARNING, "Parameter 1 expected to be Array or Object. Incorrect value given");
244-
RETURN_FALSE;
245-
}
246-
247242
if (php_url_encode_hash_ex(HASH_OF(formdata), &formstr, prefix, prefix_len, NULL, 0, NULL, 0, (Z_TYPE_P(formdata) == IS_OBJECT ? formdata : NULL), arg_sep, (int)enc_type) == FAILURE) {
248243
if (formstr.s) {
249244
smart_str_free(&formstr);

ext/standard/tests/strings/http_build_query_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ $result = http_build_query(null);
1010

1111
?>
1212
--EXPECTF--
13-
Warning: http_build_query(): Parameter 1 expected to be Array or Object. %s value given in %s on line %d
13+
Warning: http_build_query() expects parameter 1 to be array, null given in %s on line %d

0 commit comments

Comments
 (0)