From b195f383f2474cb0ec68bead4467079bfd136f60 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 13 Jul 2022 15:10:15 +0200 Subject: [PATCH] Always clone root package before adding it to a RootPackageRepo to avoid issues with plugins, fixes #10940 --- src/Composer/Command/BaseDependencyCommand.php | 2 +- src/Composer/Command/CheckPlatformReqsCommand.php | 2 +- src/Composer/Command/HomeCommand.php | 2 +- src/Composer/Command/ShowCommand.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/BaseDependencyCommand.php b/src/Composer/Command/BaseDependencyCommand.php index ba48173da..78eeaea85 100644 --- a/src/Composer/Command/BaseDependencyCommand.php +++ b/src/Composer/Command/BaseDependencyCommand.php @@ -59,7 +59,7 @@ class BaseDependencyCommand extends BaseCommand $platformOverrides = $composer->getConfig()->get('platform') ?: array(); $installedRepo = new InstalledRepository(array( - new RootPackageRepository($composer->getPackage()), + new RootPackageRepository(clone $composer->getPackage()), $composer->getRepositoryManager()->getLocalRepository(), new PlatformRepository(array(), $platformOverrides), )); diff --git a/src/Composer/Command/CheckPlatformReqsCommand.php b/src/Composer/Command/CheckPlatformReqsCommand.php index 73aee9551..aa5b95e46 100644 --- a/src/Composer/Command/CheckPlatformReqsCommand.php +++ b/src/Composer/Command/CheckPlatformReqsCommand.php @@ -80,7 +80,7 @@ EOT $requires[$require] = array($link); } - $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage()))); + $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository(clone $composer->getPackage()))); foreach ($installedRepo->getPackages() as $package) { if (in_array($package->getName(), $removePackages, true)) { continue; diff --git a/src/Composer/Command/HomeCommand.php b/src/Composer/Command/HomeCommand.php index ad4a42713..775aa04b9 100644 --- a/src/Composer/Command/HomeCommand.php +++ b/src/Composer/Command/HomeCommand.php @@ -167,7 +167,7 @@ EOT if ($composer) { return array_merge( - array(new RootPackageRepository($composer->getPackage())), // root package + array(new RootPackageRepository(clone $composer->getPackage())), // root package array($composer->getRepositoryManager()->getLocalRepository()), // installed packages $composer->getRepositoryManager()->getRepositories() // remotes ); diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 6df57e08c..3e14bd834 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -167,7 +167,7 @@ EOT $lockedRepo = null; if ($input->getOption('self')) { - $package = $this->getComposer()->getPackage(); + $package = clone $this->getComposer()->getPackage(); if ($input->getOption('name-only')) { $io->write($package->getName());