From: phpbugs at rjharrison dot org Operating system: Linux (fedora core 6 i think) PHP version: 5.2.6 PHP Bug Type: SPL related Bug description: DirectoryIterator assignment within FOREACH
Description: ------------ When looping over a $directorIterator using FOREACH something goes wrong when assigning the "as" variable to an array. Reproduce code: --------------- $filePath = 'PUT YOUR TEST PATH HERE'; $dir = new DirectoryIterator($filePath); $files = array(); foreach ($dir as $file){ $files[] = $file; echo $file->getFilename(), " / ", $file->getSize(), " bytes\n"; } echo "\nSecond loop:-\n"; foreach ($files as $file2){ echo $file2->getFilename(), " / ", $file2->getSize(), " bytes\n"; } Expected result: ---------------- (Depends on the files but assuming a single file in the directory) test.php / 18 bytes . / 4096 bytes .. / 4096 bytes Second run:- test.php / 18 bytes . / 4096 bytes .. / 4096 bytes Actual result: -------------- test.php / 18 bytes . / 4096 bytes .. / 4096 bytes Second run:- / 4096 bytes / 4096 bytes / 4096 bytes -- Edit bug report at http://bugs.php.net/?id=44964&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44964&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44964&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44964&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44964&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44964&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44964&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44964&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44964&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44964&r=support Expected behavior: http://bugs.php.net/fix.php?id=44964&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44964&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44964&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44964&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44964&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44964&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44964&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44964&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44964&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44964&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44964&r=mysqlcfg