From e7121300621ac6846f2acd58aadaf6a4b9158e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 30 Nov 2020 00:59:42 +0100 Subject: [PATCH 1/2] Fix for php8 when symlink function is disabled --- src/Composer/Util/Filesystem.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index b940ced48..d18c3b387 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -601,7 +601,12 @@ class Filesystem $relativePath = $this->findShortestPath($link, $target); chdir(\dirname($link)); - $result = @symlink($relativePath, $link); + + if (function_exists('symlink')) { + $result = @symlink($relativePath, $link); + } else { + $result = false; + } chdir($cwd); From b4cb2f73215a3dabfbc972868dab348f80f5591c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 30 Nov 2020 01:34:16 +0100 Subject: [PATCH 2/2] test before chdir --- src/Composer/Util/Filesystem.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index d18c3b387..d1200dde9 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -597,16 +597,15 @@ class Filesystem */ public function relativeSymlink($target, $link) { + if (!function_exists('symlink')) { + return false; + } + $cwd = getcwd(); $relativePath = $this->findShortestPath($link, $target); chdir(\dirname($link)); - - if (function_exists('symlink')) { - $result = @symlink($relativePath, $link); - } else { - $result = false; - } + $result = @symlink($relativePath, $link); chdir($cwd);