X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=maintenance%2FimportImages.php;h=0c4ff0af50247d514bd4e5e0c3a0b11eac6c7f28;hb=b450bf0bd6551ec8f6a7c054d6e66b29cb71e43d;hp=7f8e16a6b13c95c284f0b8e501a128eba46a02d5;hpb=ecc63fb7fe1134d064772fa71493575235b809ca;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 7f8e16a6b1..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; @@ -332,7 +340,6 @@ class ImportImages extends Maintenance { if ( $this->hasOption( 'dry' ) ) { $this->output( "done.\n" ); - // @phan-suppress-next-line PhanUndeclaredMethod } elseif ( $image->recordUpload2( $archive->value, $summary,