Merge "Clarify comment in traditional gallery"
[lhc/web/wiklou.git] / maintenance / importTextFiles.php
index 70b6574..5531ffc 100644 (file)
@@ -56,14 +56,23 @@ class ImportTextFiles extends Maintenance {
                $prefix = $this->getOption( 'prefix', '' );
 
                // Get all the arguments. A loop is required since Maintenance doesn't
-               // suppport an arbitrary number of arguments.
-               $files = array();
+               // support an arbitrary number of arguments.
+               $files = [];
                $i = 0;
                while ( $arg = $this->getArg( $i++ ) ) {
                        if ( file_exists( $arg ) ) {
                                $files[$arg] = file_get_contents( $arg );
                        } else {
-                               $this->error( "Fatal error: The file '$arg' does not exist!", 1 );
+                               // use glob to support the Windows shell, which doesn't automatically
+                               // expand wildcards
+                               $found = false;
+                               foreach ( glob( $arg ) as $filename ) {
+                                       $found = true;
+                                       $files[$filename] = file_get_contents( $filename );
+                               }
+                               if ( !$found ) {
+                                       $this->error( "Fatal error: The file '$arg' does not exist!", 1 );
+                               }
                        }
                };
 
@@ -71,7 +80,7 @@ class ImportTextFiles extends Maintenance {
                $this->output( "Importing $count pages...\n" );
 
                if ( $userName === false ) {
-                       $user = User::newSystemUser( 'Maintenance script', array( 'steal' => true ) );
+                       $user = User::newSystemUser( 'Maintenance script', [ 'steal' => true ] );
                } else {
                        $user = User::newFromName( $userName );
                }