Skip to content

Commit

Permalink
Merge branch '4.4' into 5.2
Browse files Browse the repository at this point in the history
* 4.4:
  [HttpKernel] Fixes tests for PHP7.4+
  [Filesystem] fix readlink for Windows
  • Loading branch information
nicolas-grekas committed May 26, 2021
2 parents 463ff5d + 2d926eb commit 9aa1587
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,14 @@ public function readlink(string $path, bool $canonicalize = false)
return null;
}

if ('\\' === \DIRECTORY_SEPARATOR) {
if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70410) {
$path = readlink($path);
}

return realpath($path);
}

if ('\\' === \DIRECTORY_SEPARATOR) {
if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70400) {
return realpath($path);
}

Expand Down
9 changes: 7 additions & 2 deletions Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public function testRemoveCleansInvalidLinks()

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

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

Expand Down Expand Up @@ -1076,7 +1076,12 @@ public function testReadAbsoluteLink()
$this->filesystem->symlink($link1, $link2);

$this->assertEquals($file, $this->filesystem->readlink($link1));
$this->assertEquals($link1, $this->filesystem->readlink($link2));

if (!('\\' == \DIRECTORY_SEPARATOR && \PHP_MAJOR_VERSION === 7 && \PHP_MINOR_VERSION === 3)) {
// Skip for Windows with PHP 7.3.*
$this->assertEquals($link1, $this->filesystem->readlink($link2));
}

$this->assertEquals($file, $this->filesystem->readlink($link1, true));
$this->assertEquals($file, $this->filesystem->readlink($link2, true));
$this->assertEquals($file, $this->filesystem->readlink($file, true));
Expand Down

0 comments on commit 9aa1587

Please sign in to comment.