MDL-70131 cli: only allow to negate existing keys
authorMarina Glancy <marina@moodle.com>
Thu, 5 Nov 2020 17:10:13 +0000 (18:10 +0100)
committerMarina Glancy <marina@moodle.com>
Thu, 5 Nov 2020 17:10:13 +0000 (18:10 +0100)
lib/clilib.php

index f43bf8f..e6664cd 100644 (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);