diff options
author | Bill Pirkle <bpirkle@wikimedia.org> | 2018-08-02 15:10:31 -0500 |
---|---|---|
committer | Bill Pirkle <bpirkle@wikimedia.org> | 2018-08-06 14:37:49 -0500 |
commit | 2bd7259a2c88a2bcc30a9217770a64268e161305 (patch) | |
tree | 163252e7f24610d1c9bb631adfa8bade87b4a6ff /maintenance/commandLine.inc | |
parent | a14133e55c0d4bceca030a9bdb373f3ff84c15ed (diff) | |
download | mediawikicore-2bd7259a2c88a2bcc30a9217770a64268e161305.tar.gz mediawikicore-2bd7259a2c88a2bcc30a9217770a64268e161305.zip |
Make maintenance scripts fail on unknown parameters
Passing parameters not registered via standard mechanisms
(addOption/$optionsWithArgs/$optionsWihtoutArgs) will now
cause an error, unless, the script opts out via the new
setAllowUnregisteredOptions/$allowUnregisteredOptions.
Bug: T110209
Change-Id: I21957837f10852169ca3e1eeca9bf1f4052f8c0b
Diffstat (limited to 'maintenance/commandLine.inc')
-rw-r--r-- | maintenance/commandLine.inc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/maintenance/commandLine.inc b/maintenance/commandLine.inc index 8232d529470a..bb1443f6ebec 100644 --- a/maintenance/commandLine.inc +++ b/maintenance/commandLine.inc @@ -24,7 +24,7 @@ require_once __DIR__ . '/Maintenance.php'; // phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.wgPrefix -global $optionsWithArgs, $optionsWithoutArgs; +global $optionsWithArgs, $optionsWithoutArgs, $allowUnregisteredOptions; if ( !isset( $optionsWithArgs ) ) { $optionsWithArgs = []; @@ -32,19 +32,25 @@ if ( !isset( $optionsWithArgs ) ) { if ( !isset( $optionsWithoutArgs ) ) { $optionsWithoutArgs = []; } +if ( !isset( $allowUnregisteredOptions ) ) { + $allowUnregisteredOptions = false; +} class CommandLineInc extends Maintenance { public function __construct() { // phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.wgPrefix - global $optionsWithArgs, $optionsWithoutArgs; + global $optionsWithArgs, $optionsWithoutArgs, $allowUnregisteredOptions; parent::__construct(); + foreach ( $optionsWithArgs as $name ) { $this->addOption( $name, '', false, true ); } foreach ( $optionsWithoutArgs as $name ) { $this->addOption( $name, '', false, false ); } + + $this->setAllowUnregisteredOptions( $allowUnregisteredOptions ); } /** |