From 8925b4f5969412997b1621ab9e477383ea6399db Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 25 Oct 2020 12:42:35 +0100 Subject: [PATCH 1/2] Attempt fixing handling of root aliases when composer 1 reads composer 2 lock files, fixes #9337 --- src/Composer/Package/Locker.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 1adc45dc6..93ee6de97 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -254,7 +254,17 @@ class Locker { $lockData = $this->getLockData(); - return isset($lockData['aliases']) ? $lockData['aliases'] : array(); + if (!isset($lockData['aliases'])) { + return array(); + } + + foreach ($lockData['aliases'] as $index => $alias) { + if (in_array($alias['version'], array('dev-master', 'dev-default', 'dev-trunk'), true)) { + $lockData['aliases'][$index]['version'] = '9999999-dev'; + } + } + + return $lockData['aliases']; } public function getLockData() From 04e5d725f48fddf91c92b23b393bb86f2fa97faa Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 27 Oct 2020 20:53:54 +0100 Subject: [PATCH 2/2] Add docs --- src/Composer/Package/Locker.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 93ee6de97..f4e82691d 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -258,6 +258,8 @@ class Locker return array(); } + // forward compatibility with Composer 2 lock files created + // before https://github.com/composer/composer/issues/9337 was fixed foreach ($lockData['aliases'] as $index => $alias) { if (in_array($alias['version'], array('dev-master', 'dev-default', 'dev-trunk'), true)) { $lockData['aliases'][$index]['version'] = '9999999-dev';