#45181 [Opn->Csd]: chdir() should clear relative entries in stat cache
| From: | lbarnaud@php.net | Date: | Mon, 11 Aug 2008 22:44:45 +0000 |
| Subject: | #45181 [Opn->Csd]: chdir() should clear relative entries in stat cache | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-127907@lists.php.net to get a copy of this message | ||
ID: 45181
Updated by: lbarnaud@php.net
Reported By: webmaster at villagersonline dot com
-Status: Open
+Status: Closed
Bug Type: Filesystem function related
Operating System: Linux
PHP Version: 5.2.5
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2008-06-04 18:54:13] webmaster at villagersonline dot com
Description:
------------
If you check a relative pathname with is_dir(), the result is cached.
However, chdir() does not invalidate that cache. Thus, after a chdir(),
is_dir() using the same relative pathname gives invalid results.
NOTE: In truth, I'm running PHP 5.2.5, not 5.2.6. But this is on a
professional hosting service, and I can't control the version.
Reproduce code:
---------------
<?
// note that if you run this script multiple times, then all the
// mkdir()s will give errors, since they already exist. That's
// irrelevant to the bug.
// I put this all inside a subdirectory so as to not clutter up the
// pwd of the script. Again, irrelevant to the bug.
mkdir("x");
chdir("x");
clearstatcache();
// key reproduce code starts here
mkdir("y");
mkdir("z");
var_dump(is_dir("z"));
chdir("y");
var_dump(is_dir("z")); // this is where the bug is exposed
var_dump(is_dir(getcwd()."/z"));
clearstatcache();
var_dump(is_dir("z"));
?>
Expected result:
----------------
bool(true)
bool(false)
bool(false)
bool(false)
Actual result:
--------------
bool(true)
bool(true)
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45181&edit=1