From 654ecc759a021d27c011519d74483b0ed5ba095c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 24 May 2022 21:21:47 +0200 Subject: [PATCH] Check that symlink function exists before using it in path repo, fixes #10786 --- src/Composer/Downloader/PathDownloader.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index 5482bf43d..0a09fc4a8 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -279,6 +279,15 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter $allowedStrategies = array(self::STRATEGY_MIRROR); } + // Check we can use symlink() otherwise + if (!Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !function_exists('symlink')) { + if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) { + throw new \RuntimeException('Your PHP has the symlink() function disabled which does not allow Composer to use symlinks and this path repository has symlink:true in its options so copying is not allowed'); + } + $currentStrategy = self::STRATEGY_MIRROR; + $allowedStrategies = array(self::STRATEGY_MIRROR); + } + return array($currentStrategy, $allowedStrategies); }