Edit report at https://bugs.php.net/bug.php?id=54256&edit=1
ID: 54256 Updated by: [email protected] Reported by: gege2061 at homecomputing dot fr Summary: DirectoryIterator isn't iterable with a foreach -Status: Feedback +Status: No Feedback Type: Bug Package: SPL related Operating System: Debian unstable PHP Version: 5.3.5 New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. Previous Comments: ------------------------------------------------------------------------ [2012-10-26 19:34:33] maurice dot k at zend dot com The same problem occurs with Parallels Workstation under Windows 7, when using shared folders. DirectoryIterator is not iteratable using foreach. Windows 7 Parallels Workstation v6 Linux Ubuntu 12.04.1-LTS Any suggested workaround? ------------------------------------------------------------------------ [2011-09-23 07:01:25] sniper dot unreal at web dot de 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. ------------------------------------------------------------------------ [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] [email protected] 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
