Fix typo in r97044 reported in twn
[lhc/web/wiklou.git] / maintenance / importImages.php
index de10e69..f3b10ea 100644 (file)
  *      - fetch metadata from source wiki for each file to import.
  *      - commit the fetched metadata to the destination wiki while submitting.
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @ingroup Maintenance
  * @author Rob Church <robchur@gmail.com>
@@ -81,7 +96,7 @@ if ( count( $args ) > 0 ) {
                        die( "failed to read comment file: {$options['comment-file']}\n" );
                }
        }
-       else if ( isset( $options['comment'] ) ) {
+       elseif ( isset( $options['comment'] ) ) {
                $comment =  $options['comment'];
        }
 
@@ -196,8 +211,10 @@ if ( count( $args ) > 0 ) {
                                echo( " publishing {$file} by '" . $wgUser->getName() . "', comment '$commentText'... " );
                        } else {
                                $archive = $image->publish( $file );
-                               if ( WikiError::isError( $archive ) || !$archive->isGood() ) {
-                                       echo( "failed.\n" );
+                               if ( !$archive->isGood() ) {
+                                       echo( "failed. (" .
+                                               $archive->getWikiText() .
+                                               ")\n" );
                                        $failed++;
                                        continue;
                                }
@@ -224,7 +241,7 @@ if ( count( $args ) > 0 ) {
 
                        if ( isset( $options['dry'] ) ) {
                                echo( "done.\n" );
-                       } else if ( $image->recordUpload( $archive->value, $commentText, $license ) ) {
+                       } elseif ( $image->recordUpload( $archive->value, $commentText, $license ) ) {
                                # We're done!
                                echo( "done.\n" );
                                if ( $doProtect ) {
@@ -232,8 +249,8 @@ if ( count( $args ) > 0 ) {
                                                $article = new Article( $title );
                                                echo "\nWaiting for slaves...\n";
                                                // Wait for slaves.
-                                               sleep( 2.0 );
-                                               wfWaitForSlaves( 1.0 );
+                                               sleep( 2.0 ); # Why this sleep?
+                                               wfWaitForSlaves();
 
                                                echo( "\nSetting image restrictions ... " );
                                                if ( $article->updateRestrictions( $restrictions ) )
@@ -243,7 +260,7 @@ if ( count( $args ) > 0 ) {
                                }
 
                        } else {
-                               echo( "failed.\n" );
+                               echo( "failed. (at recordUpload stage)\n" );
                                $svar = 'failed';
                        }
 
@@ -292,7 +309,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 +323,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 );