From 257d2ce889bf0213900b320c7f4ca840237442ad Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 17 Jan 2020 11:33:47 +0100 Subject: [PATCH] Avoid setting the update whitelist in require command on newly created files and when the lock file is disabled --- src/Composer/Command/RequireCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index af16a3898..48851c28d 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -236,7 +236,6 @@ EOT ->setClassMapAuthoritative($authoritative) ->setApcuAutoloader($apcu) ->setUpdate(true) - ->setUpdateWhitelist(array_keys($requirements)) ->setWhitelistTransitiveDependencies($input->getOption('update-with-dependencies')) ->setWhitelistAllDependencies($input->getOption('update-with-all-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) @@ -244,6 +243,12 @@ EOT ->setPreferLowest($input->getOption('prefer-lowest')) ; + // if no lock is present, or the file is brand new, we do not do a + // partial update as this is not supported by the Installer + if (!$this->newlyCreated && $composer->getConfig()->get('lock')) { + $install->setUpdateWhitelist(array_keys($requirements)); + } + $status = $install->run(); if ($status !== 0) { $this->revertComposerFile(false);