From b8b84c2c354c5f7eaaf208b207da979624f1a4bb Mon Sep 17 00:00:00 2001 From: Liviu-Ionut Iosif Date: Thu, 28 Apr 2022 10:03:46 +0300 Subject: [PATCH] #10738 - Allow config unset for unrecognized keys (#10756) * Allow config unset for unrecognized keys * Move config key removal after all other checks Because key removal is done without matching the key in the recognized composer.json schema, leaving the key removal before other check would have stopped the execution there without reaching the specific config add (eg. composer config repo [--unset]) Co-authored-by: Liviu Iosif --- src/Composer/Command/ConfigCommand.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 390cf2969..e893e7983 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -634,11 +634,6 @@ EOT if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) { throw new \InvalidArgumentException('The ' . $settingKey . ' property can not be set in the global config.json file. Use `composer global config` to apply changes to the global composer.json'); } - if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) { - $this->configSource->removeProperty($settingKey); - - return 0; - } if (isset($uniqueProps[$settingKey])) { $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty'); @@ -801,6 +796,12 @@ EOT return 0; } + if ($input->getOption('unset')) { + $this->configSource->removeProperty($settingKey); + + return 0; + } + throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command'); }