|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-11 22:44 UTC] lbarnaud@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 09:00:01 2025 UTC |
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)