diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 0fbf7c8588304..1b9a61bb2d17c 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1073,7 +1073,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 = tsrm_realpath(file_handle.filename, NULL TSRMLS_CC); argv[php_optind-1] = file_handle.filename; SG(request_info).argv=argv+php_optind-1; diff --git a/sapi/cli/tests/bug61546.inc b/sapi/cli/tests/bug61546.inc new file mode 100644 index 0000000000000..9ea9607e22886 --- /dev/null +++ b/sapi/cli/tests/bug61546.inc @@ -0,0 +1,10 @@ + STDIN, + 1 => STDOUT, + 2 => STDERR, + ); + + /* + * The auto test tool will pass absolute path of the current script to php, + * so use proc_open to execute script as relative filename. + */ + proc_open("$php -n " . escapeshellarg($test_file) . " $func", $desc, $pipes, dirname(__FILE__)); +} + +test_func('get_current_user'); +test_func('getmyinode'); +test_func('getlastmod'); + +/* + * getmyuid and getmygid will not be affected because those two functions have fallback + * when current script can't be found such as run as php -r. listed here just for testing + */ +test_func('getmyuid'); +test_func('getmygid'); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true)