X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportImages.php;h=d0d8a4b5cd5325408d70715edf78e2b52c3e7aa5;hb=f5360c82b810a05b35e8de3f983ecf2deea1961a;hp=e4d1f096e0ca579f02bae4c2f6b679c24ca8d227;hpb=cdeb7109f223729fb8fc38e49bf03ac77b747c05;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importImages.php b/maintenance/importImages.php index e4d1f096e0..d0d8a4b5cd 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; } } @@ -332,7 +336,6 @@ class ImportImages extends Maintenance { if ( $this->hasOption( 'dry' ) ) { $this->output( "done.\n" ); - // @phan-suppress-next-line PhanUndeclaredMethod } elseif ( $image->recordUpload2( $archive->value, $summary, @@ -358,7 +361,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 ... " );