From ebfdae888363b983d692af23b618d6e882c3825c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 11 May 2022 13:52:49 +0200 Subject: [PATCH] Fix unsetting of existing props, fixes #10767, refs #10756 --- src/Composer/Command/ConfigCommand.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index e893e7983..9045f043c 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -634,6 +634,11 @@ 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'); @@ -796,6 +801,7 @@ EOT return 0; } + // handle unsetting other top level properties if ($input->getOption('unset')) { $this->configSource->removeProperty($settingKey);