Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54bee29

Browse filesBrowse files
bug #40866 [Filesystem] fix readlink() for Windows (a1812)
This PR was merged into the 4.4 branch. Discussion ---------- [Filesystem] fix readlink() for Windows | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | **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: 1) Symfony\Component\Filesystem\Tests\FilesystemTest::testRemoveCleansInvalidLinks 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 2) Symfony\Component\Filesystem\Tests\FilesystemTest::testReadAbsoluteLink 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' Commits ------- f1b95d3 [Filesystem] fix readlink for Windows
2 parents 12030e5 + f1b95d3 commit 54bee29
Copy full SHA for 54bee29

File tree

2 files changed

+9
-4
lines changed
Filter options

2 files changed

+9
-4
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,14 @@ public function readlink($path, $canonicalize = false)
416416
return null;
417417
}
418418

419-
if ('\\' === \DIRECTORY_SEPARATOR) {
419+
if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70410) {
420420
$path = readlink($path);
421421
}
422422

423423
return realpath($path);
424424
}
425425

426-
if ('\\' === \DIRECTORY_SEPARATOR) {
426+
if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70400) {
427427
return realpath($path);
428428
}
429429

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public function testRemoveCleansInvalidLinks()
376376

377377
// create symlink to nonexistent dir
378378
rmdir($basePath.'dir');
379-
$this->assertFalse('\\' === \DIRECTORY_SEPARATOR ? @readlink($basePath.'dir-link') : is_dir($basePath.'dir-link'));
379+
$this->assertFalse('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70400 ? @readlink($basePath.'dir-link') : is_dir($basePath.'dir-link'));
380380

381381
$this->filesystem->remove($basePath);
382382

@@ -1032,7 +1032,12 @@ public function testReadAbsoluteLink()
10321032
$this->filesystem->symlink($link1, $link2);
10331033

10341034
$this->assertEquals($file, $this->filesystem->readlink($link1));
1035-
$this->assertEquals($link1, $this->filesystem->readlink($link2));
1035+
1036+
if (!('\\' == \DIRECTORY_SEPARATOR && \PHP_MAJOR_VERSION === 7 && \PHP_MINOR_VERSION === 3)) {
1037+
// Skip for Windows with PHP 7.3.*
1038+
$this->assertEquals($link1, $this->filesystem->readlink($link2));
1039+
}
1040+
10361041
$this->assertEquals($file, $this->filesystem->readlink($link1, true));
10371042
$this->assertEquals($file, $this->filesystem->readlink($link2, true));
10381043
$this->assertEquals($file, $this->filesystem->readlink($file, true));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.