Has anyone encountered this oddity?
I'm checking for the existence of a number of directories in one of my unit tests. is_dir
is reporting true (1) in spite of the folder not existing at the time it is called. Code looks like this (with a few extraneous intermediate vars to ease debugging):
foreach($userfolders as $uf) {
$uf = sprintf($uf, $user_id);
$uf = ltrim($uf,'/');
$path = trim($base . '/' . $uf);
$res = is_dir($path); //returns false except last time returns 1
$this->assertFalse($res, $path);
}
Machine running Ubuntu Linux 8.04 with PHP Version 5.2.4-2ubuntu5.3
Things I have checked:
- Paths are full paths
- Same thing happens on two separate machines (both running Ubuntu)
- I have stepped through line by line in a debugger
- Paths genuinely don't exist at the point where is_dir is called
- While the code is paused on this line, I can actually drop to a shell and run the interactive php interpreter and get the correct result
- The paths are all WELL under 256 chars
- I can't imagine a permissions problem as the folder doesn't exist! The parent folder can't be causing permissions problems as the other folders in the loop are correctly reported as missing.
Comments on the PHP docs point to the odd issue with is_dir
but not this particular one.
I'm not posting this as a "please help me fix" but in the hope that somebody encountering the same thing can search here and hopefully an answer from somebody else who as seen this!