Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6ea0eb9

Browse files
committed
main: Ignore register_argc_argv when SG(request_info).argc is available
1 parent ca4a841 commit 6ea0eb9

File tree

3 files changed

+61
-13
lines changed

3 files changed

+61
-13
lines changed

‎ext/standard/tests/general_functions/bug43293_1.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ array(3) {
2121
[2]=>
2222
int(3)
2323
}
24-
bool(false)
24+
array(0) {
25+
}

‎main/php_variables.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ PHPAPI zend_result php_hash_environment(void)
786786
{
787787
memset(PG(http_globals), 0, sizeof(PG(http_globals)));
788788
zend_activate_auto_globals();
789-
if (PG(register_argc_argv)) {
789+
if (PG(register_argc_argv)||SG(request_info).argc) {
790790
php_build_argv(SG(request_info).query_string, &PG(http_globals)[TRACK_VARS_SERVER]);
791791
}
792792
return SUCCESS;
@@ -875,19 +875,17 @@ static bool php_auto_globals_create_server(zend_string *name)
875875
if (PG(variables_order) && (strchr(PG(variables_order),'S') || strchr(PG(variables_order),'s'))) {
876876
php_register_server_variables();
877877

878-
if (PG(register_argc_argv)) {
879-
if (SG(request_info).argc) {
880-
zval *argc, *argv;
878+
if (SG(request_info).argc) {
879+
zval *argc, *argv;
881880

882-
if ((argc = zend_hash_find_ex_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGC), 1)) != NULL &&
883-
(argv = zend_hash_find_ex_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGV), 1)) != NULL) {
884-
Z_ADDREF_P(argv);
885-
zend_hash_update(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGV), argv);
886-
zend_hash_update(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGC), argc);
887-
}
888-
} else {
889-
php_build_argv(SG(request_info).query_string, &PG(http_globals)[TRACK_VARS_SERVER]);
881+
if ((argc = zend_hash_find_ex_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGC), 1)) != NULL &&
882+
(argv = zend_hash_find_ex_ind(&EG(symbol_table), ZSTR_KNOWN(ZEND_STR_ARGV), 1)) != NULL) {
883+
Z_ADDREF_P(argv);
884+
zend_hash_update(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGV), argv);
885+
zend_hash_update(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), ZSTR_KNOWN(ZEND_STR_ARGC), argc);
890886
}
887+
} else if (PG(register_argc_argv)) {
888+
php_build_argv(SG(request_info).query_string, &PG(http_globals)[TRACK_VARS_SERVER]);
891889
}
892890

893891
} else {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Testing $argc and $argv handling (cli, register_argc_argv=0)
3+
--INI--
4+
register_argc_argv=0
5+
variables_order=GPS
6+
--ARGS--
7+
ab cd ef 123 test
8+
--FILE--
9+
<?php
10+
11+
var_dump(
12+
$argc,
13+
$argv,
14+
$_SERVER['argc'],
15+
$_SERVER['argv'],
16+
);
17+
18+
?>
19+
--EXPECTF--
20+
int(6)
21+
array(6) {
22+
[0]=>
23+
string(%d) "%s"
24+
[1]=>
25+
string(2) "ab"
26+
[2]=>
27+
string(2) "cd"
28+
[3]=>
29+
string(2) "ef"
30+
[4]=>
31+
string(3) "123"
32+
[5]=>
33+
string(4) "test"
34+
}
35+
int(6)
36+
array(6) {
37+
[0]=>
38+
string(%d) "%s"
39+
[1]=>
40+
string(2) "ab"
41+
[2]=>
42+
string(2) "cd"
43+
[3]=>
44+
string(2) "ef"
45+
[4]=>
46+
string(3) "123"
47+
[5]=>
48+
string(4) "test"
49+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /