MDL-70131 cli: only allow to negate existing keys

This commit is contained in:
Marina Glancy
2020-11-06 09:30:08 +08:00
committed by Andrew Nicols
parent 6d138e3675
commit 8a9a4ee4f3
+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);