imageImport --check-userblock checks if the user used for importing was blocked
authorDaniel Kinzler <daniel@users.mediawiki.org>
Fri, 2 Oct 2009 10:04:41 +0000 (10:04 +0000)
committerDaniel Kinzler <daniel@users.mediawiki.org>
Fri, 2 Oct 2009 10:04:41 +0000 (10:04 +0000)
maintenance/importImages.php

index ec5a16b..c41bfa6 100644 (file)
@@ -45,6 +45,14 @@ if (isset($options['protect']) && $options['protect'] == 1)
                $user = User::newFromName( 'Maintenance script' );
        $wgUser = $user;
 
+       # Get block check. If a value is given, this specified how often the check is performed
+       if ( isset( $options['check-userblock'] ) ) {
+               if ( !$options['check-userblock'] ) $checkUserBlock = 1;
+               else $checkUserBlock = (int)$options['check-userblock']; 
+       } else {
+               $checkUserBlock = false;
+       }
+
        # Get --from 
        $from = @$options['from'];
 
@@ -96,6 +104,14 @@ 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." );
+                                       break;
+                               }
+                       }
+
                        # Check existence
                        $image = wfLocalFile( $title );
                        if( $image->exists() ) {
@@ -239,6 +255,7 @@ Options:
                         aborted imports. <name> should be the file's canonical database form.
 --sleep=<sec>          Sleep between files. Useful mostly for debugging.
 --user=<username>      Set username of uploader, default 'Maintenance script'
+--check-userblock      Check if the user got blocked during import.
 --comment=<text>       Set upload summary comment, default 'Importing image file'.
 --comment-file=<file>          Set upload summary comment the the content of <file>.
 --comment-ext=<ext>    Causes the comment for each file to be loaded from a file with the same name