#43977 [Fbk->Opn]: chdir() not working with absolute path / CWD not properly reset
ID: 43977
User updated by: sysdev at gmx dot net
Reported By: sysdev at gmx dot net
-Status: Feedback
+Status: Open
Bug Type: Directory function related
Operating System: Windows Server 2003
PHP Version: 5.2.5
New Comment:
Seems to be fine for the first chdir-call, but the first getcwd-call
still shows the CWD of the last PHP-script-run before, not the base
directory of the current PHP-script.
Previous Comments:
------------------------------------------------------------------------
[2008-03-26 12:31:16] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
------------------------------------------------------------------------
[2008-01-29 21:49:37] sysdev at gmx dot net
Description:
------------
IIS 6 with PHP 5 SAPI:
In some cases, the CWD of a PHP-script run is not properly reset to the
script's directory. Its instead the directory of another previously run
script.
chdir() with an absulote path fails in these cases if the desired path
is no child of the script's path itself, while chdir() with a relative
path to the same destination succeedes.
Reproduce code:
---------------
Script located in d:\webshare\web3
echo '<div>CWD is '.getcwd().'</div>';
chdir( 'd:\\webshare\\web3' );
echo '<div>CWD is '.getcwd().'</div>';
chdir( 'd:\\webshare\\web3\\test' );
echo '<div>CWD is '.getcwd().'</div>';
Expected result:
----------------
Script located in d:\webshare\web3
CWD is 'd:\webshare\web3'
CWD is 'd:\webshare\web3'
CWD is 'd:\webshare\web3\test'
Actual result:
--------------
Script located in d:\webshare\web3
CWD is 'd:\webshare\another\scripts\path'
Warning: chdir() [function.chdir]: No such file or directory (errno 2)
in D:\webshare\web3\test.php on line 4
CWD is 'd:\webshare\another\scripts\path'
CWD is 'd:\webshare\web3\test'
-- or sometimes --
Script located in d:\webshare\web3
CWD is 'd:\webshare\another\scripts\path'
Warning: chdir() [function.chdir]: No error (errno 0) in
D:\webshare\web3\test.php on line 4
CWD is 'd:\webshare\another\scripts\path'
CWD is 'd:\webshare\web3\test'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43977&edit=1
Thread (8 messages)