Page MenuHomePhabricator

unblock.php

Authored By
Urbanecm
Aug 27 2020, 11:48 AM
Size
958 B
Referenced Files
None
Subscribers
None

unblock.php

<?php
require_once '/srv/mediawiki/php-1.36.0-wmf.6/maintenance' . '/Maintenance.php';
use MediaWiki\Block\DatabaseBlock;
class Unblockusers extends Maintenance {
public function execute() {
$performer = User::newSystemUser( 'Maintenance script', [ 'steal' => true ] );
$targets = explode("\n", file_get_contents('/home/urbanecm/targets.txt'));
foreach ($targets as $target) {
$block = DatabaseBlock::newFromTarget($target);
if($block === null) {
continue;
}
$block->delete();
$logEntry = new ManualLogEntry( 'block', 'unblock' );
$logEntry->setPerformer($performer);
$logEntry->setComment('Removing blocks exceeding $wgBlockCIDRLimit (T243980)');
$logEntry->setTarget(TitleValue::tryNew(NS_USER, $target));
$logEntry->setRelations(['ipb_id' => $block->getId()]);
$logId = $logEntry->insert();
$logEntry->publish($logId);
}
}
}
$maintClass = Unblockusers::class;
require_once RUN_MAINTENANCE_IF_MAIN;

File Metadata

Mime Type
text/x-php
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8513824
Default Alt Text
unblock.php (958 B)

Event Timeline