X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupBlocks.php;h=db51e4b3d495dd941bacb87aefe40faaa1aa30ad;hb=ddf87314b6102ee0558ee201d4fc123bdd168b35;hp=41d492d4d8d0dcc140e2fe7a2287edaed27d1dbe;hpb=47818f1b44a3525dff1c07778aaef65d06b8ae89;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupBlocks.php b/maintenance/cleanupBlocks.php index 41d492d4d8..db51e4b3d4 100644 --- a/maintenance/cleanupBlocks.php +++ b/maintenance/cleanupBlocks.php @@ -23,6 +23,8 @@ require_once __DIR__ . '/Maintenance.php'; +use MediaWiki\Block\DatabaseBlock; + /** * Maintenance script to clean up user blocks with user names not matching the * 'user' table. @@ -39,7 +41,7 @@ class CleanupBlocks extends Maintenance { public function execute() { $db = $this->getDB( DB_MASTER ); - $blockQuery = Block::getQueryInfo(); + $blockQuery = DatabaseBlock::getQueryInfo(); $max = $db->selectField( 'ipblocks', 'MAX(ipb_user)' ); @@ -77,14 +79,14 @@ class CleanupBlocks extends Maintenance { $blockQuery['joins'] ); foreach ( $res2 as $row2 ) { - $block = Block::newFromRow( $row2 ); + $block = DatabaseBlock::newFromRow( $row2 ); if ( !$bestBlock ) { $bestBlock = $block; continue; } // Find the most-restrictive block. Can't use - // Block::chooseBlock because that's for IP blocks, not + // DatabaseBlock::chooseBlock because that's for IP blocks, not // user blocks. $keep = null; if ( $keep === null && $block->getExpiry() !== $bestBlock->getExpiry() ) { @@ -92,11 +94,12 @@ class CleanupBlocks extends Maintenance { $keep = $block->getExpiry() > $bestBlock->getExpiry(); } if ( $keep === null ) { - foreach ( [ 'createaccount', 'sendemail', 'editownusertalk' ] as $action ) { - if ( $block->prevents( $action ) xor $bestBlock->prevents( $action ) ) { - $keep = $block->prevents( $action ); - break; - } + if ( $block->isCreateAccountBlocked() xor $bestBlock->isCreateAccountBlocked() ) { + $keep = $block->isCreateAccountBlocked(); + } elseif ( $block->isEmailBlocked() xor $bestBlock->isEmailBlocked() ) { + $keep = $block->isEmailBlocked(); + } elseif ( $block->isUsertalkEditAllowed() xor $bestBlock->isUsertalkEditAllowed() ) { + $keep = $block->isUsertalkEditAllowed(); } } @@ -148,5 +151,5 @@ class CleanupBlocks extends Maintenance { } } -$maintClass = "CleanupBlocks"; +$maintClass = CleanupBlocks::class; require_once RUN_MAINTENANCE_IF_MAIN;