com php-src: Use ARRAY_OR_OBJECT arg in http_build _query: ext/standard/http.c ext/standard/tests/string s/http_build_query_error.phpt
| From: | Nikita Popov | Date: | Thu, 11 Oct 2018 11:04:08 +0000 |
| Subject: | com php-src: Use ARRAY_OR_OBJECT arg in http_build _query: ext/standard/http.c ext/standard/tests/string s/http_build_query_error.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-103434@lists.php.net to get a copy of this message | ||
Commit: 4ca5b357717ccf79b86966d04fc03287e551acdc
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 11 Oct 2018 12:56:12 +0200
Parents: 900ee5705fb6bbdabe0cc4681ff5b764e9222af8
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4ca5b357717ccf79b86966d04fc03287e551acdc
Log:
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.
Changed paths:
M ext/standard/http.c
M ext/standard/tests/strings/http_build_query_error.phpt
Diff:
diff --git a/ext/standard/http.c b/ext/standard/http.c
index 293258b..aec0e60 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 30155e6..2975d2d 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