Fix extra element bug with $_SERVER['argc'] and $_SERVER['argv']
When a file is executed on the command line without the --file argument, $_SERVER['argv'] contains an extraneous empty string at the beginning of the array. (Note this bug does not occur when the --file argument is used.) Github pull request 767: https://github.com/facebook/hiphop-php/pull/767
Esse commit está contido em:
@@ -1047,11 +1047,9 @@ Variant invoke_file(CStrRef s, bool once, const char *currentDir) {
|
||||
SystemGlobals* g = (SystemGlobals*)get_global_variables();
|
||||
Variant& v_argc = g->GV(argc);
|
||||
Variant& v_argv = g->GV(argv);
|
||||
if (!more(v_argc, int64_t(1))) {
|
||||
if (!more(v_argc, int64_t(0))) {
|
||||
return true;
|
||||
}
|
||||
v_argc--;
|
||||
v_argv.dequeue();
|
||||
String s2 = toString(v_argv.rvalAt(int64_t(0), AccessFlags::Error));
|
||||
if (invoke_file_impl(r, s2, once, "")) {
|
||||
return r;
|
||||
|
||||
@@ -683,7 +683,7 @@ static void prepare_args(int &argc, char **&argv, const StringVec &args,
|
||||
const char *file) {
|
||||
argv = (char **)malloc((args.size() + 2) * sizeof(char*));
|
||||
argc = 0;
|
||||
if (file) {
|
||||
if (*file) {
|
||||
argv[argc++] = (char*)file;
|
||||
}
|
||||
for (int i = 0; i < (int)args.size(); i++) {
|
||||
@@ -1031,8 +1031,8 @@ static int execute_program_impl(int argc, char **argv) {
|
||||
|
||||
if (!po.file.empty()) {
|
||||
Repo::setCliFile(po.file);
|
||||
} else if (new_argc >= 2) {
|
||||
Repo::setCliFile(new_argv[1]);
|
||||
} else if (new_argc >= 1) {
|
||||
Repo::setCliFile(new_argv[0]);
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<?php
|
||||
|
||||
var_dump($argc, count($argv));
|
||||
var_dump($argc, count($argv));
|
||||
var_dump($_SERVER['argc'], count($_SERVER['argv']));
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
int(1)
|
||||
int(1)
|
||||
int(1)
|
||||
int(1)
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário