|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79806 realpath() erroneously resolves link to link
Submitted: 2020-07-07 15:19 UTC Modified: 2020-07-28 12:05 UTC
From: Assigned: cmb (profile)
Status: Closed Package: Filesystem function related
PHP Version: 7.3 OS: Windows NTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
17 + 41 = ?
Subscribe to this entry?

 [2020-07-07 15:19 UTC]
On Windows realpath() only resolves the first level (soft or hard)
link, but does not go further.  This does neither match the
behavior on Linux (as far as I know), not the documentation which

| The resulting path will have no symbolic link, […]

Test script:
touch(__DIR__ . '/link.txt');
symlink(__DIR__ . '/link.txt', __DIR__ . '/link1.lnk');
symlink(__DIR__ . '/link1.lnk', __DIR__ . '/link2.lnk');

var_dump(substr(realpath(__DIR__ . '/link2.lnk'), strlen(__DIR__)));

Expected result:
string(9) "\link.txt"

Actual result:
string(10) "\link1.lnk"


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-07 15:19 UTC]
-Assigned To: +Assigned To: cmb
 [2020-07-15 16:38 UTC]
-PHP Version: 7.4.7 +PHP Version: 7.3
 [2020-07-15 16:39 UTC]
The following pull request has been associated:

Patch Name: Fix #79806: realpath() erroneously resolves link to link
On GitHub:
 [2020-07-27 13:12 UTC]
Automatic comment on behalf of
Log: Fix #79806: realpath() erroneously resolves link to link
 [2020-07-27 13:12 UTC]
-Status: Assigned +Status: Closed
 [2020-07-27 15:54 UTC]
Automatic comment on behalf of
Log: Revert &quot;Fix #79806: realpath() erroneously resolves link to link&quot;
 [2020-07-27 15:54 UTC]
-Status: Closed +Status: Re-Opened
 [2020-07-28 12:05 UTC]
-Status: Re-Opened +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Mar 30 12:03:40 2023 UTC