diff options
author | Xinchen Hui <laruence@php.net> | 2012-04-30 12:09:22 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2012-04-30 12:09:22 +0800 |
commit | bae56a87f81b91cd815604b0f404f616b0d73c2b (patch) | |
tree | 4df775d20a8054e2ed0f2818aa1fe1b9b8a4cc46 /sapi/cli/php_cli.c | |
parent | 9aff3a1156efdfae7660d5b5e7a6d8b29c263722 (diff) | |
download | php-git-bae56a87f81b91cd815604b0f404f616b0d73c2b.tar.gz |
Fixed bug #61546 (functions related to current script failed when chdir() in cli sapi).
Diffstat (limited to 'sapi/cli/php_cli.c')
-rw-r--r-- | sapi/cli/php_cli.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 0fbf7c8588..f26db43151 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -648,7 +648,7 @@ int main(int argc, char *argv[]) int orig_optind=php_optind; char *orig_optarg=php_optarg; char *arg_free=NULL, **arg_excp=&arg_free; - char *script_file=NULL; + char *script_file=NULL, *translated_path = NULL; int interactive=0; volatile int module_started = 0; volatile int request_started = 0; @@ -1053,8 +1053,13 @@ int main(int argc, char *argv[]) if (script_file) { if (cli_seek_file_begin(&file_handle, script_file, &lineno TSRMLS_CC) != SUCCESS) { goto err; + } else { + char real_path[MAXPATHLEN]; + if (VCWD_REALPATH(script_file, real_path)) { + translated_path = strdup(real_path); + } + script_filename = script_file; } - script_filename = script_file; } else { /* We could handle PHP_MODE_PROCESS_STDIN in a different manner */ /* here but this would make things only more complicated. And it */ @@ -1073,7 +1078,7 @@ int main(int argc, char *argv[]) SG(request_info).argc=argc-php_optind+1; arg_excp = argv+php_optind-1; arg_free = argv[php_optind-1]; - SG(request_info).path_translated = file_handle.filename; + SG(request_info).path_translated = translated_path? translated_path : file_handle.filename; argv[php_optind-1] = file_handle.filename; SG(request_info).argv=argv+php_optind-1; |