MDL-70131 cli: only allow to negate existing keys

This commit is contained in:
Marina Glancy
2020-11-05 18:10:13 +01:00
parent c50c904c9e
commit 8c1917588d
+2 -1
View File
@@ -106,7 +106,8 @@ function cli_get_params(array $longoptions, array $shortmapping=null) {
$key = reset($parts);
$value = true;
if (substr($key, 0, 3) === 'no-') {
if (substr($key, 0, 3) === 'no-' && !array_key_exists($key, $longoptions)
&& array_key_exists(substr($key, 3), $longoptions)) {
// Support flipping the boolean value.
$value = !$value;
$key = substr($key, 3);