fix for different sources of upload comments
authorDaniel Kinzler <daniel@users.mediawiki.org>
Wed, 9 Dec 2009 21:58:20 +0000 (21:58 +0000)
committerDaniel Kinzler <daniel@users.mediawiki.org>
Wed, 9 Dec 2009 21:58:20 +0000 (21:58 +0000)
maintenance/importImages.php

index 97be19a..9f9bcae 100644 (file)
@@ -65,7 +65,7 @@ if (isset($options['protect']) && $options['protect'] == 1)
        if ( $limit ) $limit = (int)$limit; 
 
        # Get the upload comment
-       $comment = 'Importing image file';
+       $comment = NULL;
 
        if ( isset( $options['comment-file'] ) ) {
                $comment =  file_get_contents( $options['comment-file'] );
@@ -107,7 +107,7 @@ if (isset($options['protect']) && $options['protect'] == 1)
                        if ( $checkUserBlock && ( ( $processed % $checkUserBlock ) == 0 ) ) {
                                $user->clearInstanceCache( 'name' ); //reload from DB!
                                if ( $user->isBlocked() ) {
-                                       echo( $user->getName() . " was blocked! Aborting." );
+                                       echo( $user->getName() . " was blocked! Aborting.\n" );
                                        break;
                                }
                        }
@@ -147,23 +147,27 @@ if (isset($options['protect']) && $options['protect'] == 1)
                        if ( $commentExt ) {
                                $f = findAuxFile( $file, $commentExt );
                                if ( !$f ) {
-                                       echo( " No comment file with extension {$commentExt} found for {$file}, using default comment. " );
+                                       echo( " No comment file with extension {$commentExt} found for {$file}. " );
+                                       $commentText = $comment;
                                } else {
                                        $commentText = file_get_contents( $f );
                                        if ( !$f ) {
-                                               echo( " Failed to load comment file {$f}, using default comment. " );
+                                               echo( " Failed to load comment file {$f}. " );
+                                               $commentText = $comment;
+                                       } else if ( $comment ) {
+                                               $commentText = trim( $commentText ) . "\n\n" . trim( $comment );
                                        }
                                }
-
-                               if ( $commentText && $comment ) {
-                                       $commentText = trim( $commentText ) . "\n\n" . trim( $comment );
-                               }
                        }
 
                        if ( !$commentText ) {
                                $commentText = $comment;
                        }
 
+                       if ( !$commentText ) {
+                               $commentText = 'Importing image file';
+                       }
+
                        # Import the file       
                        if ( isset( $options['dry'] ) ) {
                                echo( " publishing {$file}... " );