1
0
Fork 0

#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 <liviu.iosif@code932.com>
pull/10635/head
Liviu-Ionut Iosif 2022-04-28 10:03:46 +03:00 committed by GitHub
parent e918b6001b
commit b8b84c2c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -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');
}