Bug #70651 [NEW]: Inconsistent usage of Current Working Directory

From: Date: Tue, 06 Oct 2015 15:04:30 +0000
Subject: Bug #70651 [NEW]: Inconsistent usage of Current Working Directory
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196431@lists.php.net to get a copy of this message
From: deivid dot garcia dot garcia at gmail dot com Operating system: Windows/IIS/FastCGI PHP version: 7.0.0RC4 Package: Directory function related Bug Type: Bug Bug description:Inconsistent usage of Current Working Directory Description: ------------ is_dir and is_file are returning inconsistent results when being called from code registered by register_shutdown_function(). Test script: --------------- <?php function printline($line) { echo $line . "<br/>\r\n"; } function _is_dir($dir) { printline("is_dir({$dir}): " . (is_dir($dir) ? "true" : "false")); } function _is_file($file) { printline("is_file({$file}): " . (is_file($file) ? "true" : "false")); } global $test; $test = 1; function test_dir() { global $test; printline("workding directory:" . getcwd()); // sites/all is a regular directory in the webroot _is_dir('sites/all'); // sites/default is a symlink directory in the webroot _is_dir('sites/default'); // index.php is where this script in the webroot _is_file('index.php'); if ($test == 2) { // php.exe not in webroot _is_file('php.exe'); // cron.php is a file in the webroot _is_file('cron.php'); } } test_dir(); printline("shutdown"); register_shutdown_function('test_dir'); return; Expected result: ---------------- When $test == 1 Actual output: workding directory:D:\REPOSITORIOS_SABENTIS\drupal7 is_dir(sites/all): true is_dir(sites/default): true is_file(index.php): true shutdown workding directory:C:\Program Files (x86)\PHP\php5.6 is_dir(sites/all): false is_dir(sites/default): false is_file(index.php): true Expected Output: workding directory:D:\REPOSITORIOS_SABENTIS\drupal7 is_dir(sites/all): true is_dir(sites/default): true is_file(index.php): true shutdown workding directory:C:\Program Files (x86)\PHP\php5.6 is_dir(sites/all): false is_dir(sites/default): false is_file(index.php): false When $test == 2 Actual Output = Expected Output: workding directory:D:\REPOSITORIOS_SABENTIS\drupal7 is_dir(sites/all): true is_dir(sites/default): true is_file(index.php): true is_file(php.exe): false is_file(cron.php): true shutdown workding directory:C:\Program Files (x86)\PHP\php5.6 is_dir(sites/all): false is_dir(sites/default): false is_file(index.php): false is_file(php.exe): true is_file(cron.php): false -- Edit bug report at https://bugs.php.net/bug.php?id=70651&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70651&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70651&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70651&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70651&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70651&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70651&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70651&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70651&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70651&r=support Expected behavior: https://bugs.php.net/fix.php?id=70651&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70651&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70651&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70651&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70651&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70651&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70651&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70651&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70651&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70651&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70651&r=mysqlcfg

« previous php.bugs (#196431) next »