|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-02-19 11:34 UTC] mesaverde228 at gmail dot com
Description: ------------ There is some difference in interpretation symlinked folder on different platforms Test script: --------------- https://gist.github.com/inri13666/4f7484af32ac7eba81b0d1bf8a5a5111 Expected result: ---------------- I assume that result for `index.php` should be almost the same. Also possibly __DIR__ should point to the symlink(junction) path instead of a physical path. Actual result: -------------- https://gist.github.com/inri13666/4f7484af32ac7eba81b0d1bf8a5a5111 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 22:00:01 2025 UTC |
The only bug I can see here is that realpath() on a junction is resolving it D:\test\symlinkedcachefolder>php -r "var_dump(realpath('D:/test/symlinkedcachefolder'));" string(23) "D:\test\realcachefolder" when last I knew PHP deliberately did not - only symlinks. Do you agree?if I change mklink /J D:\test\symlinkedcachefolder D:\test\realcachefolder to mklink /d D:\test\symlinkedcachefolder D:\test\realcachefolder I got following response from CMD symbolic link created for D:\test\symlinkedcachefolder <<===>> D:\test\realcachefolder But the script "index.php" works the same as for "junction" D:\test\symlinkedcachefolder>php index.php array(4) { ["realpath(__DIR__)"]=> string(23) "D:\test\realcachefolder" ["realpath("D:\test\symlinkedcachefolder\gretta")"]=> bool(false) ["dirname(__DIR__)"]=> string(7) "D:\test" ["dirname(__DIR__ . "\gretta")"]=> string(23) "D:\test\realcachefolder" }Ok, install git and use "ln" from distribution to create symbolik link like on Linux system rm -rf D:\test\symlinkedcachefolder ln -s D:\test\realcachefolder D:\test\symlinkedcachefolder dir output D:\test>dir Volume in drive D is dev Volume Serial Number is ECD3-824B Directory of D:\test 02/19/2019 11:14 PM <DIR> . 02/19/2019 11:14 PM <DIR> .. 02/19/2019 09:51 PM <DIR> realcachefolder 02/19/2019 11:14 PM <DIR> symlinkedcachefolder 0 File(s) 0 bytes 4 Dir(s) 34,891,960,320 bytes free Next use steps from previous STR php -r "var_dump(realpath('D:/test/symlinkedcachefolder'));" php -r "var_dump(__DIR__);" Will output D:\test\symlinkedcachefolder>php -r "var_dump(realpath('D:/test/symlinkedcachefolder'));" string(28) "D:\test\symlinkedcachefolder" D:\test\symlinkedcachefolder>php -r "var_dump(__DIR__);" string(28) "D:\test\symlinkedcachefolder" and script will return following D:\test\symlinkedcachefolder>php index.php array(4) { ["realpath(__DIR__)"]=> string(28) "D:\test\symlinkedcachefolder" ["realpath("D:\test\symlinkedcachefolder\gretta")"]=> bool(false) ["dirname(__DIR__)"]=> string(7) "D:\test" ["dirname(__DIR__ . "\gretta")"]=> string(28) "D:\test\symlinkedcachefolder" } Totally different result comparing to junctions or native soft links in windows and not the same as on Linux fo links created using "ln" toolWindows does support symlinked directories. They can even be symlinks to UNC paths. Symlinked directories can be relative or absolute. C:\>mklink /? Creates a symbolic link. MKLINK [[/D] | [/H] | [/J]] Link Target /D Creates a directory symbolic link. Default is a file symbolic link. /H Creates a hard link instead of a symbolic link. /J Creates a Directory Junction. Link Specifies the new symbolic link name. Target Specifies the path (relative or absolute) that the new link refers to.