php is_dir returns true for non-existent folder
<p>Has anyone encountered this oddity?</p>

<p>I'm checking for the existence of a number of directories in one of my unit tests. <code>is_dir</code> 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):</p>

<pre><code>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-&gt;assertFalse($res, $path);
}
</code></pre>

<p>Machine running Ubuntu Linux 8.04 with PHP Version 5.2.4-2ubuntu5.3</p>

<p>Things I have checked:</p>

<ul>
<li>Paths are full paths</li>
<li>Same thing happens on two separate machines (both running Ubuntu)</li>
<li>I have stepped through line by line in a debugger</li>
<li>Paths genuinely don't exist at the point where is_dir is called</li>
<li>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</li>
<li>The paths are all WELL under 256 chars</li>
<li>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.</li>
</ul>

<p>Comments on the PHP docs point to the odd issue with <code>is_dir</code> but not this particular one.</p>

<p>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 <em>hopefully</em> an answer from somebody else who as seen this!</p>
