X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportImages.php;h=0c4ff0af50247d514bd4e5e0c3a0b11eac6c7f28;hb=9ddd146c262806e993ea66994f367a0a795e762d;hp=f5d9359d43713c97c1f3b77e85a73fd3f7ff4168;hpb=c99b4bd4e646c3911a4d8b26dc77fa5c89ee7f91;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importImages.php b/maintenance/importImages.php index f5d9359d43..0c4ff0af50 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -32,10 +32,10 @@ * @author Mij */ -use MediaWiki\MediaWikiServices; - require_once __DIR__ . '/Maintenance.php'; +use MediaWiki\MediaWikiServices; + class ImportImages extends Maintenance { public function __construct() { @@ -127,6 +127,8 @@ class ImportImages extends Maintenance { public function execute() { global $wgFileExtensions, $wgUser, $wgRestrictionLevels; + $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); + $processed = $added = $ignored = $skipped = $overwritten = $failed = 0; $this->output( "Importing Files\n\n" ); @@ -198,7 +200,8 @@ class ImportImages extends Maintenance { $title = Title::makeTitleSafe( NS_FILE, $base ); if ( !is_object( $title ) ) { $this->output( - "{$base} could not be imported; a valid title cannot be produced\n" ); + "{$base} could not be imported; a valid title cannot be produced\n" + ); continue; } @@ -213,10 +216,12 @@ class ImportImages extends Maintenance { if ( $checkUserBlock && ( ( $processed % $checkUserBlock ) == 0 ) ) { $user->clearInstanceCache( 'name' ); // reload from DB! - // @TODO Use PermissionManager::isBlockedFrom() instead. - if ( $user->getBlock() ) { - $this->output( $user->getName() . " was blocked! Aborting.\n" ); - break; + if ( $permissionManager->isBlockedFrom( $user, $title ) ) { + $this->output( + "{$user->getName()} is blocked from {$title->getPrefixedText()}! skipping.\n" + ); + $skipped++; + continue; } } @@ -242,7 +247,8 @@ class ImportImages extends Maintenance { if ( $dupes ) { $this->output( - "{$base} already exists as {$dupes[0]->getName()}, skipping\n" ); + "{$base} already exists as {$dupes[0]->getName()}, skipping\n" + ); $skipped++; continue; } @@ -270,7 +276,8 @@ class ImportImages extends Maintenance { if ( $wgUser === false ) { # user does not exist in target wiki $this->output( - "failed: user '$real_user' does not exist in target wiki." ); + "failed: user '$real_user' does not exist in target wiki." + ); continue; } } @@ -287,7 +294,8 @@ class ImportImages extends Maintenance { $commentText = file_get_contents( $f ); if ( !$commentText ) { $this->output( - " Failed to load comment file {$f}, using default comment. " ); + " Failed to load comment file {$f}, using default comment. " + ); } } } @@ -318,7 +326,7 @@ class ImportImages extends Maintenance { $archive = $image->publish( $file, $flags, $publishOptions ); if ( !$archive->isGood() ) { $this->output( "failed. (" . - $archive->getWikiText( false, false, 'en' ) . + $archive->getMessage( false, false, 'en' )->text() . ")\n" ); $failed++; continue; @@ -357,7 +365,7 @@ class ImportImages extends Maintenance { # Protect the file $this->output( "\nWaiting for replica DBs...\n" ); // Wait for replica DBs. - sleep( 2.0 ); # Why this sleep? + sleep( 2 ); # Why this sleep? wfWaitForSlaves(); $this->output( "\nSetting image restrictions ... " );