ID: 48788 Updated by: il...@php.net Reported By: craig dot marvelley at boxuk dot com -Status: Open +Status: Closed Bug Type: SPL related Operating System: Linux (Debian) PHP Version: 5.3.0 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. To avoid breaking how existing code works a new constant is introduced for the RecursiveDirectoryIterator() that directs the code to follow symlinks. This constant RecursiveDirectoryIterator::FOLLOW_SYMLINKS can be passed a flag to the constructor to trigger symlink following Previous Comments: ------------------------------------------------------------------------ [2009-07-03 15:10:54] craig dot marvelley at boxuk dot com Description: ------------ In a Windows environment, RecursiveDirectoryIterator will treat symlinked directories as valid directories, descending into them accordingly. However on Linux this isn't the case, with a symlink being treated as a file (leaf). Reproduce code: --------------- <?php // create a 'proper' directory with a file mkdir('new_dir'); file_put_contents('new_dir/test.txt', 'test'); // create a symlink to our directory symlink('new_dir', 'symlink_dir'); $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__)); foreach($iterator as $object) { echo $object->getFilename() . "\n"; } Expected result: ---------------- On Windows Vista, I get this (executed in file test.php): test.txt test.txt test.php Which I would expect; the symlinked directory is treated as a regular directory, so the test file appears twice. Actual result: -------------- On Linux (same scenario): test.php symlink_dir test.txt . .. . .. The symlinked directory appears, but as a leaf; the contents of the directory are not discovered. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48788&edit=1