r57285 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57284‎ | r57285 | r57286 >
Date:10:04, 2 October 2009
Author:daniel
Status:ok
Tags:
Comment:
imageImport --check-userblock checks if the user used for importing was blocked
Modified paths:
  • /trunk/phase3/maintenance/importImages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/importImages.php
@@ -45,6 +45,14 @@
4646 $user = User::newFromName( 'Maintenance script' );
4747 $wgUser = $user;
4848
 49+ # Get block check. If a value is given, this specified how often the check is performed
 50+ if ( isset( $options['check-userblock'] ) ) {
 51+ if ( !$options['check-userblock'] ) $checkUserBlock = 1;
 52+ else $checkUserBlock = (int)$options['check-userblock'];
 53+ } else {
 54+ $checkUserBlock = false;
 55+ }
 56+
4957 # Get --from
5058 $from = @$options['from'];
5159
@@ -96,6 +104,14 @@
97105 }
98106 }
99107
 108+ if ( $checkUserBlock && ( ( $processed % $checkUserBlock ) == 0 ) ) {
 109+ $user->clearInstanceCache( 'name' ); //reload from DB!
 110+ if ( $user->isBlocked() ) {
 111+ echo( $user->getName() . " was blocked! Aborting." );
 112+ break;
 113+ }
 114+ }
 115+
100116 # Check existence
101117 $image = wfLocalFile( $title );
102118 if( $image->exists() ) {
@@ -239,6 +255,7 @@
240256 aborted imports. <name> should be the file's canonical database form.
241257 --sleep=<sec> Sleep between files. Useful mostly for debugging.
242258 --user=<username> Set username of uploader, default 'Maintenance script'
 259+--check-userblock Check if the user got blocked during import.
243260 --comment=<text> Set upload summary comment, default 'Importing image file'.
244261 --comment-file=<file> Set upload summary comment the the content of <file>.
245262 --comment-ext=<ext> Causes the comment for each file to be loaded from a file with the same name

Status & tagging log