Skip to content

Commit 2634b13

Browse files
committed
Deprecate parse_str() without second argument
1 parent 7a73c5f commit 2634b13

File tree

9 files changed

+36
-17
lines changed

9 files changed

+36
-17
lines changed

Zend/tests/bug73181.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function x() {
1111
x();
1212

1313
?>
14-
--EXPECT--
14+
--EXPECTF--
15+
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d
1516
array(2) {
1617
[1]=>
1718
string(0) ""

Zend/tests/parse_str_with_unpack.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ function test() {
1111
test();
1212

1313
?>
14-
--EXPECT--
14+
--EXPECTF--
15+
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d
1516
int(42)

Zend/tests/this_in_parse_str.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ function foo() {
99
foo();
1010
?>
1111
--EXPECTF--
12+
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d
13+
1214
Fatal error: Uncaught Error: Cannot re-assign $this in %sthis_in_parse_str.php:3
1315
Stack trace:
1416
#0 %sthis_in_parse_str.php(3): parse_str('this=42')

ext/standard/string.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,6 +4563,8 @@ PHP_FUNCTION(parse_str)
45634563
return;
45644564
}
45654565

4566+
php_error_docref(NULL, E_DEPRECATED, "Calling parse_str() without the result argument is deprecated");
4567+
45664568
symbol_table = zend_rebuild_symbol_table();
45674569
ZVAL_ARR(&tmp, symbol_table);
45684570
sapi_module.treat_data(PARSE_STRING, res, &tmp);

ext/standard/tests/strings/bug24208.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ $a = $b = $c = "oops";
66
parse_str("a=1&b=2&c=3");
77
var_dump($a, $b, $c);
88
?>
9-
--EXPECT--
9+
--EXPECTF--
10+
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d
1011
string(1) "1"
1112
string(1) "2"
1213
string(1) "3"

ext/standard/tests/strings/parse_str_basic1.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ var_dump($res3_array);
3636
--EXPECTF--
3737
*** Testing parse_str() : basic functionality ***
3838
Basic test WITHOUT result arg
39+
40+
Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d
3941
NULL
4042
string(4) "val1"
4143
string(4) "val2"
@@ -73,4 +75,4 @@ array(3) {
7375
["third"]=>
7476
string(4) "val3"
7577
}
76-
===DONE===
78+
===DONE===

ext/standard/tests/strings/parse_str_basic2.phpt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@ arg_separator.input = "/"
1212
echo "*** Testing parse_str() : non-default arg_separator.input specified ***\n";
1313

1414
$s1 = "first=val1/second=val2/third=val3";
15-
var_dump(parse_str($s1));
16-
var_dump($first, $second, $third);
15+
var_dump(parse_str($s1, $result));
16+
var_dump($result);
1717

1818
?>
1919
===DONE===
20-
--EXPECTF--
20+
--EXPECT--
2121
*** Testing parse_str() : non-default arg_separator.input specified ***
2222
NULL
23-
string(4) "val1"
24-
string(4) "val2"
25-
string(4) "val3"
26-
===DONE===
23+
array(3) {
24+
["first"]=>
25+
string(4) "val1"
26+
["second"]=>
27+
string(4) "val2"
28+
["third"]=>
29+
string(4) "val3"
30+
}
31+
===DONE===
496 Bytes
Binary file not shown.

ext/standard/tests/strings/parse_str_basic4.phpt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ var_dump($res);
2222

2323
echo "\nTest string with badly formed % numbers\n";
2424
$str = "first=%41&second=%a&third=%b";
25-
var_dump(parse_str($str));
26-
var_dump($first, $second, $third);
25+
var_dump(parse_str($str, $res));
26+
var_dump($res);
2727

2828
echo "\nTest string with non-binary safe name\n";
2929
$str = "arr.test[1]=sid&arr test[4][two]=fred";
@@ -66,9 +66,14 @@ array(2) {
6666

6767
Test string with badly formed % numbers
6868
NULL
69-
string(1) "A"
70-
string(2) "%a"
71-
string(2) "%b"
69+
array(3) {
70+
["first"]=>
71+
string(1) "A"
72+
["second"]=>
73+
string(2) "%a"
74+
["third"]=>
75+
string(2) "%b"
76+
}
7277

7378
Test string with non-binary safe name
7479
NULL
@@ -84,4 +89,4 @@ array(1) {
8489
}
8590
}
8691
}
87-
===DONE===
92+
===DONE===

0 commit comments

Comments
 (0)