X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportImages.php;h=954f36d3a29e4d4956d3170b1811c101c3356a80;hb=9ef0f8ff0307bab339805b7ee3bae126716ff6db;hp=4065978e89aa480da3edd680c615c1c82975b351;hpb=31c334794c8164e44353e22aed71bb27caca80e3;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 4065978e89..954f36d3a2 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. " + ); } } }