|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38820 chdir(".") and chdir("..") don't work with Apache 2.0+
Submitted: 2006-09-14 06:40 UTC Modified: 2006-09-27 07:32 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ras at fyn dot dk Assigned:
Status: Closed Package: Directory function related
PHP Version: 5.1.6 OS: Win XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ras at fyn dot dk
New email:
PHP Version: OS:


 [2006-09-14 06:40 UTC] ras at fyn dot dk
When using chdir() with relative folders (e.g. "." and ".."), under Apache 2.0 or newer, using either the php5 module or the CGI binary, the function changes the current directory to the Apache application folder, rather than a folder relative to the current folder.

Tested with PHP 5.1.6, and current 5.2.x-dev, under Apache 2.2.3, 2.0.59 and 2.0.55 - all tested with both the php5 module and the CGI binary, all with same result.

Bug appears to be specific to the Windows port of PHP.

Apache 1.3.37 exhibits no similar problems.

I filed this bug with Apache, but Ruediger Pluem at says that "this is clearly a PHP bug":

Reproduce code:
// create the "test" folder before running the script!

echo getcwd() . "<br />";
echo getcwd() . "<br />";
echo getcwd() . "<br />";
echo getcwd();

Expected result:

Actual result:
C:\Programmer\Apache Group
C:\Programmer\Apache Group


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-14 08:50 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-09-14 11:21 UTC] ras at fyn dot dk
Tony, as said - I already tried the current snapshot, downloaded the latest development release yesterday.

Unless it was fixed and updated today, I'm sorry, but I don't have time to uninstall, reinstall and reconfigure Apache and PHP again just now. My current Apache 1.3 installation works just fine for me - I only use the Windows release for testing and development on my workstation...
 [2006-09-25 13:04 UTC]
Not reproducible on Linux with Apache2.0.55 worker/prefork.
 [2006-09-26 06:19 UTC] ras at fyn dot dk
No, it does not reproduce on Linux, as said, the bug appears to be specific to the Windows port.
 [2006-09-26 17:30 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-09-27 07:04 UTC] ras at fyn dot dk
Installed under a clean Apache 2.2.3, and it worked!

Thank you for your fast response! :)

Should I change the status of this bug, or will an admin do that?
 [2006-09-27 07:32 UTC]
Fixed -> closed.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 21 03:03:36 2021 UTC