From: David Barratt Date: Fri, 19 Jul 2019 18:32:08 +0000 (-0400) Subject: Allow partially blocked users to import images X-Git-Tag: 1.34.0-rc.0~376^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=45fcf5f94f7a13308665d637e2a5cd81550d1493;p=lhc%2Fweb%2Fwiklou.git 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 --- 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; } }