From: RQuadling at GMail dot com Operating system: Windows XP SP2 PHP version: 5.3CVS-2008-06-24 (CVS) PHP Bug Type: SPL related Bug description: SPLFileInfo::getPathInfo() returns incorrect values.
Description: ------------ Using RII(RID()) to traverse a directory tree. Using ->getFileInfo() to see what it returned. The result contains an array with 2 entries, which are based upon the directory of the object making the call and not the filename. It might be me (hey, I've got more bogus bugs than actual ones, but I think this is a real one this time!). I'm drawn in 2 ways for the expected results. Either ... 1 - "pathName" and "fileName" should match getPathname() and getFilename() or 2 - getPathInfo() should return the same values as pathinfo() Reproduce code: --------------- <?php // Create a small directory structure in %TEMP% $s_Root = getenv('TEMP') . DIRECTORY_SEPARATOR . 'RAQ1'; $s_Dir = $s_Root . DIRECTORY_SEPARATOR . 'RAQ2' . DIRECTORY_SEPARATOR . 'RAQ3' . DIRECTORY_SEPARATOR . 'RAQ4'; mkdir($s_Dir, 0777, True); // Add a file to the new tree. file_put_contents($s_Dir . DIRECTORY_SEPARATOR . 'test.txt', 'This is a test'); // Iterate. foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($s_Root)) as $o_File) { echo 'Pathname:', $o_File->getPathname(), PHP_EOL, 'Filename:', $o_File->getFilename(), PHP_EOL; $a_PathInfo = $o_File->getPathinfo(); var_dump($a_PathInfo); } // Remove test files and tree. unlink($s_Dir . DIRECTORY_SEPARATOR . 'test.txt'); rmdir($s_Dir); rmdir(dirname($s_Dir)); rmdir(dirname(dirname($s_Dir))); rmdir(dirname(dirname(dirname($s_Dir)))); Expected result: ---------------- D:\TEMP\RAQ1\RAQ2\RAQ3\RAQ4\test.txt object(SplFileInfo)#8 (2) { ["pathName":"SplFileInfo":private]=> string(22) "D:\TEMP\RAQ1\RAQ2\RAQ3\RAQ4\test.txt" ["fileName":"SplFileInfo":private]=> string(27) "test.txt" } pathName should match getPathname() filename should match getFilename() OR splfileinfo::getPathInfo() should return the same values as pathinfo() Actual result: -------------- Pathname:D:\TEMP\RAQ1\RAQ2\RAQ3\RAQ4\test.txt Filename:test.txt object(SplFileInfo)#8 (2) { ["pathName":"SplFileInfo":private]=> string(22) "D:\TEMP\RAQ1\RAQ2\RAQ3" ["fileName":"SplFileInfo":private]=> string(27) "D:\TEMP\RAQ1\RAQ2\RAQ3\RAQ4" } -- Edit bug report at http://bugs.php.net/?id=45345&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45345&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45345&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45345&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45345&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45345&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45345&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45345&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45345&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45345&r=support Expected behavior: http://bugs.php.net/fix.php?id=45345&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45345&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45345&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45345&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45345&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45345&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45345&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45345&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45345&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45345&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45345&r=mysqlcfg