Skip to content

Commit 37f67a9

Browse files
committed
ext/standard: Fix GH-9316
http_build_query() default null argument for is implicitly coerced to string Closes GH-9316
1 parent c524dc6 commit 37f67a9

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

NEWS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.3.1
44

5-
5+
- Standard
6+
. Fixed GH-9316 (http_build_query() default null argument for $arg_separator
7+
is implicitly coerced to string). (Girgias)
68

79
23 Nov 2023, PHP 8.3.0
810

ext/standard/http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ PHP_FUNCTION(http_build_query)
226226
Z_PARAM_ARRAY_OR_OBJECT(formdata)
227227
Z_PARAM_OPTIONAL
228228
Z_PARAM_STRING(prefix, prefix_len)
229-
Z_PARAM_STR(arg_sep)
229+
Z_PARAM_STR_OR_NULL(arg_sep)
230230
Z_PARAM_LONG(enc_type)
231231
ZEND_PARSE_PARAMETERS_END();
232232

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug GH-9316 (http_build_query() default null argument for $arg_separator is implicitly coerced to string)
3+
--FILE--
4+
<?php
5+
6+
$data = [
7+
'hello' => 'world',
8+
'foo' => 'bar',
9+
];
10+
11+
var_dump(http_build_query(
12+
$data,
13+
encoding_type: PHP_QUERY_RFC3986
14+
));
15+
?>
16+
--EXPECT--
17+
string(19) "hello=world&foo=bar"

0 commit comments

Comments
 (0)