From e3527ea37f26cb357401b1d9c57cdc51a96972cd Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 6 Jun 2022 15:22:41 +0200 Subject: [PATCH] Detect broken symlinks when checking for a package's presence, fixes #6708 --- src/Composer/Installer/LibraryInstaller.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 71f45e8e4..d05b8e63f 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -90,7 +90,19 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface return true; } - return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath); + if (Platform::isWindows() && $this->filesystem->isJunction($installPath)) { + return true; + } + + if (is_link($installPath)) { + if (realpath($installPath) === false) { + return false; + } + + return true; + } + + return false; } /**