From: Operating system: Windows Vista/7 PHP version: Irrelevant Package: *Directory/Filesystem functions Bug Type: Bug Bug description:realpath not resolving symlinks corrrectly
Description: ------------ When creating a symlink in Windows to an absolute path with a lower case drive letter, PHP will not resolve the canonicalized absolute pathname (realpath) correctly. This is obvious when you have nested symlinks. When you run realpath of a nested symlink it returns the next symlink it links to, rather than the top absolute pathname. On Linux it works correctly. One work around that can be used is: $link = 'f:\link3'; do { $link = realpath($link); } while (realpath($link) !== false && $link !== realpath($link)); Test script: --------------- Windows test: F:\>mkdir target F:\>mklink /D link1 f:\target F:\>mklink /D link2 f:\link1 F:\>mklink /D link3 f:\link2 F:\>php -r "var_dump(realpath('link3'));" Linux test: $ mkdir target $ ln -s target link1 $ ln -s link1 link2 $ ln -s link2 link3 $ php -r "var_dump(realpath('link3'));" Expected result: ---------------- Windows test: string(9) "F:\target" Linux test: string(12) "/root/target" Actual result: -------------- Windows test: string(9) "f:\\link2" Linux test: string(12) "/root/target" -- Edit bug report at https://bugs.php.net/bug.php?id=61933&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61933&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61933&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61933&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=61933&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61933&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=61933&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=61933&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=61933&r=needscript Try newer version: https://bugs.php.net/fix.php?id=61933&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=61933&r=support Expected behavior: https://bugs.php.net/fix.php?id=61933&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=61933&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=61933&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=61933&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61933&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=61933&r=dst IIS Stability: https://bugs.php.net/fix.php?id=61933&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=61933&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=61933&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=61933&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=61933&r=mysqlcfg