From acddc1f5e4fa394bcea7dacba3b9200e6cb6a823 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 13 Oct 2022 16:29:08 +0200 Subject: [PATCH] Fix require failing to do a dry-run when requiring a package with a stability flag, fixes #11112 --- src/Composer/Command/RequireCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 6ce7a0c69..241654f8e 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -14,6 +14,7 @@ namespace Composer\Command; use Composer\DependencyResolver\Request; use Composer\Package\CompletePackageInterface; +use Composer\Package\Loader\RootPackageLoader; use Composer\Util\Filesystem; use Composer\Util\PackageSorter; use Seld\Signal\SignalHandler; @@ -410,6 +411,15 @@ EOT } $rootPackage->setRequires($links['require']); $rootPackage->setDevRequires($links['require-dev']); + + // extract stability flags & references as they weren't present when loading the unmodified composer.json + $references = $rootPackage->getReferences(); + $references = RootPackageLoader::extractReferences($requirements, $references); + $rootPackage->setReferences($references); + $stabilityFlags = $rootPackage->getStabilityFlags(); + $stabilityFlags = RootPackageLoader::extractStabilityFlags($requirements, $rootPackage->getMinimumStability(), $stabilityFlags); + $rootPackage->setStabilityFlags($stabilityFlags); + unset($stabilityFlags, $references); } $updateDevMode = !$input->getOption('update-no-dev');