Bug #61933 [Fbk]: realpath not resolving symlinks corrrectly
| From: | pajoye@php.net | Date: | Thu, 03 May 2012 23:04:48 +0000 |
| Subject: | Bug #61933 [Fbk]: realpath not resolving symlinks corrrectly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-170145@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61933&edit=1
ID: 61933
Updated by: pajoye@php.net
Reported by: david at panmedia dot co dot nz
Summary: realpath not resolving symlinks corrrectly
Status: Feedback
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Windows Vista/7
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I mean on linux too, is it TS or NTS?
Previous Comments:
------------------------------------------------------------------------
[2012-05-03 22:58:18] david at panmedia dot co dot nz
@pajoye I am using VC9 NTS version on Windows.
------------------------------------------------------------------------
[2012-05-03 22:43:36] pajoye@php.net
It does work, it gives you the target of the given link.
The only difference is an OS specific implementation where all links are resolved.
I suppose you use a TS php on windows and a NTS on linux, right?
------------------------------------------------------------------------
[2012-05-03 21:32:36] david at panmedia dot co dot nz
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 this bug report at https://bugs.php.net/bug.php?id=61933&edit=1