Followup r77748, throw NEW MWException
[lhc/web/wiklou.git] / maintenance / importImages.php
index 4712325..befbe64 100644 (file)
@@ -33,7 +33,7 @@ if ( count( $args ) > 0 ) {
        if ( isset( $options['protect'] ) && isset( $options['unprotect'] ) )
                        die( "Cannot specify both protect and unprotect.  Only 1 is allowed.\n" );
 
-if ( isset( $options['protect'] ) && $options['protect'] == 1 )
+       if ( isset( $options['protect'] ) && $options['protect'] == 1 )
                        die( "You must specify a protection option.\n" );
 
        # Prepare the list of allowed extensions
@@ -72,8 +72,8 @@ if ( isset( $options['protect'] ) && $options['protect'] == 1 )
        $limit = @$options['limit'];
        if ( $limit ) $limit = (int)$limit;
 
-       # Get the upload comment
-       $comment = NULL;
+       # Get the upload comment. Provide a default one in case there's no comment given.
+       $comment = 'Importing image file';
 
        if ( isset( $options['comment-file'] ) ) {
                $comment =  file_get_contents( $options['comment-file'] );
@@ -186,7 +186,7 @@ if ( isset( $options['protect'] ) && $options['protect'] == 1 )
                                }
 
                                if ( !$commentText ) {
-                                       $commentText = $comment ? $comment : 'Importing image file';
+                                       $commentText = $comment;
                                }
                        }
 
@@ -196,7 +196,7 @@ if ( isset( $options['protect'] ) && $options['protect'] == 1 )
                                echo( " publishing {$file} by '" . $wgUser->getName() . "', comment '$commentText'... " );
                        } else {
                                $archive = $image->publish( $file );
-                               if ( WikiError::isError( $archive ) || !$archive->isGood() ) {
+                               if ( !$archive->isGood() ) {
                                        echo( "failed.\n" );
                                        $failed++;
                                        continue;
@@ -292,7 +292,7 @@ Options:
 --overwrite            Overwrite existing images with the same name (default is to skip them)
 --limit=<num>          Limit the number of images to process. Ignored or skipped images are not counted.
 --from=<name>          Ignore all files until the one with the given name. Useful for resuming
-                        aborted imports. <name> should be the file's canonical database form.
+                                               aborted imports. <name> should be the file's canonical database form.
 --skip-dupes           Skip images that were already uploaded under a different name (check SHA1)
 --sleep=<sec>          Sleep between files. Useful mostly for debugging.
 --user=<username>      Set username of uploader, default 'Maintenance script'
@@ -306,7 +306,7 @@ Options:
 --protect=<protect>     Specify the protect value (autoconfirmed,sysop)
 --unprotect             Unprotects all uploaded images
 --source-wiki-url   if specified, take User and Comment data for each imported file from this URL.
-                    For example, --source-wiki-url="http://en.wikipedia.org/"
+                                       For example, --source-wiki-url="http://en.wikipedia.org/"
 
 TEXT;
        exit( 1 );