From 45fcf5f94f7a13308665d637e2a5cd81550d1493 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Fri, 19 Jul 2019 14:32:08 -0400 Subject: [PATCH 1/1] Allow partially blocked users to import images If a user is partially blocked they are prevented from importing images. These users should be allowed to import images unless they are blocked from existing images that they are going to overwrite or the File namespace. Bug: T228539 Change-Id: I251a3c151f81df828c0f45c0d78d479e94ff1880 --- maintenance/importImages.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/maintenance/importImages.php b/maintenance/importImages.php index f5d9359d43..f6be840d71 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" ); @@ -213,10 +215,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; } } -- 2.20.1