maintenance: Detect "unknown module name" error in manageForeignResources
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 6 Oct 2018 03:05:38 +0000 (04:05 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sat, 6 Oct 2018 03:09:54 +0000 (04:09 +0100)
Previously, `manageForeignResources.php update foo` would output
"Done!", which is very similar to "... updating foo\nDone!".

The module argument is now validated, just like how the
action argument was validated already.

Change-Id: Ia7c87de5d86b9d1a411485cac43b1529fe88a59f

maintenance/resources/manageForeignResources.php

index aa22c68..5317b28 100644 (file)
@@ -69,10 +69,15 @@ TEXT
                        file_get_contents( __DIR__ . '/foreign-resources.yaml' )
                );
                $module = $this->getArg( 1, 'all' );
-               foreach ( $registry as $moduleName => $info ) {
-                       if ( $module !== 'all' && $moduleName !== $module ) {
-                               continue;
-                       }
+               if ( $module === 'all' ) {
+                       $modules = $registry;
+               } elseif ( isset( $registry[ $module ] ) ) {
+                       $modules = [ $module => $registry[ $module ] ];
+               } else {
+                       $this->fatalError( 'Unknown module name.' );
+               }
+
+               foreach ( $modules as $moduleName => $info ) {
                        $this->verbose( "\n### {$moduleName}\n\n" );
                        $destDir = "{$IP}/resources/lib/$moduleName";