From 4ca5b357717ccf79b86966d04fc03287e551acdc Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 11 Oct 2018 12:56:12 +0200 Subject: [PATCH] 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. --- ext/standard/http.c | 7 +------ ext/standard/tests/strings/http_build_query_error.phpt | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/ext/standard/http.c b/ext/standard/http.c index 293258b1aaf..aec0e60d89a 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -232,18 +232,13 @@ PHP_FUNCTION(http_build_query) zend_long enc_type = PHP_QUERY_RFC1738; ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_ZVAL(formdata) + Z_PARAM_ARRAY_OR_OBJECT(formdata) Z_PARAM_OPTIONAL Z_PARAM_STRING(prefix, prefix_len) Z_PARAM_STRING(arg_sep, arg_sep_len) Z_PARAM_LONG(enc_type) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); - if (Z_TYPE_P(formdata) != IS_ARRAY && Z_TYPE_P(formdata) != IS_OBJECT) { - php_error_docref(NULL, E_WARNING, "Parameter 1 expected to be Array or Object. Incorrect value given"); - RETURN_FALSE; - } - 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) { if (formstr.s) { smart_str_free(&formstr); diff --git a/ext/standard/tests/strings/http_build_query_error.phpt b/ext/standard/tests/strings/http_build_query_error.phpt index 30155e62a39..2975d2d7230 100644 --- a/ext/standard/tests/strings/http_build_query_error.phpt +++ b/ext/standard/tests/strings/http_build_query_error.phpt @@ -10,4 +10,4 @@ $result = http_build_query(null); ?> --EXPECTF-- -Warning: http_build_query(): Parameter 1 expected to be Array or Object. %s value given in %s on line %d \ No newline at end of file +Warning: http_build_query() expects parameter 1 to be array, null given in %s on line %d