Edit report at https://bugs.php.net/bug.php?id=54256&edit=1
ID: 54256 Comment by: sniper dot unreal at web dot de Reported by: gege2061 at homecomputing dot fr Summary: DirectoryIterator isn't iterable with a foreach Status: Feedback Type: Bug Package: SPL related Operating System: Debian unstable PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Hi Everyone, I had the same problem on ubuntu (which is also debian based). After installing the VirtualBox guest additions that are on the ISO that comes with VirtualBox instead of the guest additions bundled with debian/ubuntu solved the issue. So you just have do install the guest additions on your VM and it should work fine. Previous Comments: ------------------------------------------------------------------------ [2011-03-17 10:26:03] gege2061 at homecomputing dot fr The problem is reproducible with php5.3-201103170730 ------------------------------------------------------------------------ [2011-03-16 21:13:31] johan...@php.net Please try using this snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Works perfectly for me. "PHP version: 5.3.5-1" is none of our version numbers. MAybe your distribution has patched this somehow. Please test our version or talk to the distributor. ------------------------------------------------------------------------ [2011-03-15 15:23:26] gege2061 at homecomputing dot fr Description: ------------ Hello, DirectoryIterator is iterable in a while but not in a foreach. This bug is reproductible only on a vboxsf filesystem. I run this script on Debian sid hosted on Windows XP (NTFS formated hd). I have no problem when I execute this script on Windows or on a virtual disk. Test script: --------------- <?php function test_iterator($dirname) { $files = array(); $dir = new DirectoryIterator($dirname); while($dir->valid()) { $files[] = (string)$dir->current(); $dir->next(); } return $files; } function test_iterator_bug($dirname) { $files = array(); $dir = new DirectoryIterator($dirname); foreach($dir as $file) { $files[] = (string)$file; } return $files; } echo 'PHP version: ' . phpversion() . "\n\n"; $dirname = dirname(__FILE__); foreach (array('iterator', 'iterator_bug') as $test_name) { echo "--- {$test_name} ---\n"; $foo = "test_{$test_name}"; var_dump($foo($dirname)); echo "\n"; } Expected result: ---------------- PHP version: 5.3.5-1 --- iterator --- array(3) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(9) "index.php" } --- iterator_bug --- array(3) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(9) "index.php" } Actual result: -------------- PHP version: 5.3.5-1 --- iterator --- array(3) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(9) "index.php" } --- iterator_bug --- array(0) { } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54256&edit=1