Bug #79806 [NEW]: realpath() erroneously resolves link to link
From: cmb
Operating system: Windows NTS
PHP version: 7.4.7
Package: Filesystem function related
Bug Type: Bug
Bug description:realpath() erroneously resolves link to link
Description:
------------
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
states:
| The resulting path will have no symbolic link, [â¦]
Test script:
---------------
<?php
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"
--
Edit bug report at https://bugs.php.net/bug.php?id=79806&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79806&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79806&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79806&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79806&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79806&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79806&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79806&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79806&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79806&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79806&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79806&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79806&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79806&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79806&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79806&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79806&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79806&r=mysqlcfg
Thread (5 messages)
- cmb@php.net