From:             webmaster at villagersonline dot com
Operating system: Linux
PHP version:      5.2.6
PHP Bug Type:     *Directory/Filesystem functions
Bug description:  chdir should clear relative entries in stat cache

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 bug report at http://bugs.php.net/?id=45181&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45181&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45181&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45181&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45181&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45181&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45181&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45181&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45181&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45181&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45181&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45181&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45181&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45181&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45181&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45181&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45181&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45181&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45181&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45181&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45181&r=mysqlcfg

Reply via email to