From cc820306eb5d7503d26f41daa39dde2d431ec5f9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 25 Nov 2024 16:23:10 +0100 Subject: [PATCH] Ensure installed.php data is sorted deterministically, fixes #12197 --- src/Composer/Repository/FilesystemRepository.php | 8 ++++++++ tests/Composer/Test/Repository/Fixtures/installed.php | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Composer/Repository/FilesystemRepository.php b/src/Composer/Repository/FilesystemRepository.php index ec37573f2..abb9f125e 100644 --- a/src/Composer/Repository/FilesystemRepository.php +++ b/src/Composer/Repository/FilesystemRepository.php @@ -329,6 +329,14 @@ REGEX; ksort($versions['versions']); ksort($versions); + foreach ($versions['versions'] as $name => $version) { + foreach (['aliases', 'replaced', 'provided'] as $key) { + if (isset($versions['versions'][$name][$key])) { + sort($versions['versions'][$name][$key], SORT_NATURAL); + } + } + } + return $versions; } diff --git a/tests/Composer/Test/Repository/Fixtures/installed.php b/tests/Composer/Test/Repository/Fixtures/installed.php index dbdda5e3c..3bfbc15ab 100644 --- a/tests/Composer/Test/Repository/Fixtures/installed.php +++ b/tests/Composer/Test/Repository/Fixtures/installed.php @@ -65,10 +65,10 @@ 'foo/impl' => array( 'dev_requirement' => false, 'provided' => array( - 0 => '^1.1', - 1 => '1.2', - 2 => '1.4', - 3 => '2.0', + 0 => '1.2', + 1 => '1.4', + 2 => '2.0', + 3 => '^1.1', ), ), 'foo/impl2' => array(