Respect undeclared command line options
authorTim Starling <tstarling@wikimedia.org>
Thu, 10 Mar 2016 05:18:13 +0000 (16:18 +1100)
committerTim Starling <tstarling@wikimedia.org>
Thu, 10 Mar 2016 05:22:21 +0000 (16:22 +1100)
This was broken by I847d45684ccd. We should really give an error when an
undeclared option is given (not ignore the option as in the previous
code), but most commandLine.inc users rely on undeclared options being
passed through to the $options global, and the change in I847d45684ccd
was apparently accidental.

Change-Id: Icec654a386bc79bf3e4ba81644c3c51ac5e093ba

maintenance/Maintenance.php

index 777eddd..a08297a 100644 (file)
@@ -752,17 +752,19 @@ abstract class Maintenance {
 
                if ( isset( $this->mParams[$option] ) ) {
                        $multi = $this->mParams[$option]['multiOccurrence'];
-                       $exists = array_key_exists( $option, $options );
-                       if ( $multi && $exists ) {
-                               $options[$option][] = $value;
-                       } elseif ( $multi ) {
-                               $options[$option] = [ $value ];
-                       } elseif ( !$exists ) {
-                               $options[$option] = $value;
-                       } else {
-                               $this->error( "\nERROR: $option parameter given twice\n" );
-                               $this->maybeHelp( true );
-                       }
+               } else {
+                       $multi = false;
+               }
+               $exists = array_key_exists( $option, $options );
+               if ( $multi && $exists ) {
+                       $options[$option][] = $value;
+               } elseif ( $multi ) {
+                       $options[$option] = [ $value ];
+               } elseif ( !$exists ) {
+                       $options[$option] = $value;
+               } else {
+                       $this->error( "\nERROR: $option parameter given twice\n" );
+                       $this->maybeHelp( true );
                }
        }