-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Filesystem] fix readlink() for Windows #40866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Filesystem] fix readlink() for Windows #40866
Conversation
98bd15f
to
2ca8c35
Compare
I'm not sure if skipping a test is a good idea, but the green bars clearly improve my mood :) |
:D |
<?php
// check behavior functions realpath, readlink, and component Symfony Filesystem for windows
require_once __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\Filesystem\Filesystem;
$dir = __DIR__ . DIRECTORY_SEPARATOR . 'dir';
mkdir($dir);
$file = $dir . DIRECTORY_SEPARATOR . 'file';
$link1 = $dir . DIRECTORY_SEPARATOR . 'link1';
$link2 = $dir . DIRECTORY_SEPARATOR . 'link2';
touch($file);
symlink($file, $link1);
symlink($link1, $link2);
$fs = new Filesystem();
echo 'PHP: ' . PHP_VERSION . PHP_EOL;
echo 'realpath: ' . realpath($link2) . PHP_EOL;
echo 'readlink: ' . readlink($link2) . PHP_EOL;
echo '$fs->readlink($link2, true): ' . $fs->readlink($link2, true) . PHP_EOL;
echo '$fs->readlink($link2): ' . $fs->readlink($link2) . PHP_EOL;
unlink($file);
unlink($link1);
unlink($link2);
rmdir($dir); b - before patch, a - after patch
###conclusion:
What to do with PHP 7.3.* ? Correct me, maybe I am confusing or missing something. |
how check set PROJECT_DIR=C:\symfony
set PHPUNIT=%PROJECT_DIR%/phpunit^
--colors=never^
--bootstrap %PROJECT_DIR%/vendor\autoload.php^
--configuration %PROJECT_DIR%/phpunit.xml.dist %PROJECT_DIR%/src/Symfony/Component/Filesystem
FOR %%V IN (
7.1.3,
7.1.33,
7.2.15,
7.2.34,
7.3.0,
7.3.15,
7.3.27,
7.3.28,
7.4.0,
7.4.9,
7.4.10,
7.4.15,
7.4.16,
7.4.18,
8.0.0,
8.0.1,
8.0.2,
8.0.3,
8.0.5,
8.0.6
) DO (
c:\php\%%V\php %PHPUNIT%
@if errorlevel 1 (
exit /b
)
) |
51a0b9c
to
76358d0
Compare
Hi @nicolas-grekas, please check my code. |
imho need to edit the description, the current one is misleading
https://symfony.com/doc/4.4/components/filesystem.html#readlink |
76358d0
to
bd5861f
Compare
Bug report for PHP7.3.27 https://bugs.php.net/bug.php?id=80993 |
Answer from php.net
I think we did everything we could (fixed for 8.0 and >=7.4.10) for behavior our component |
bd5861f
to
f1b95d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(what a mess :) )
Thank you @a1812. |
This PR was merged into the 4.4 branch. Discussion ---------- fix readlink description remove description readlink() for Windows misleading see symfony/symfony#40866 Commits ------- a2dd7ee fix readlink description
How to reproduce
Windows 10.0.19042.928, PHP 8.0.3, PHPUnit 9.5.4
run as Administrator
C:\php\php.exe ./phpunit --bootstrap ./vendor/autoload.php --configuration ./phpunit.xml.dist ./src/Symfony/Component/Filesystem/Tests
There were 2 failures:
Failed asserting that 'C:\Users\albat\AppData\Local\Temp\1618836823.005.2057903605\directory\dir' is false.
D:\Z__PHP_PROJECT\symfony\src\Symfony\Component\Filesystem\Tests\FilesystemTest.php:379
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'C:\Users\albat\AppData\Local\Temp\1618836823.1681.131301953\dir\link'
+'C:\Users\albat\AppData\Local\Temp\1618836823.1681.131301953\file'