$username = wfMessage( 'spambot_username' )->text();
$wgUser = User::newSystemUser( $username );
if ( !$wgUser ) {
- $this->error( "Invalid username specified in 'spambot_username' message: $username", true );
- }
- // Create the user if necessary
- if ( !$wgUser->getId() ) {
- $wgUser->addToDatabase();
+ $this->fatalError( "Invalid username specified in 'spambot_username' message: $username" );
}
+ // Hack: Grant bot rights so we don't flood RecentChanges
+ $wgUser->addGroup( 'bot' );
+
$spec = $this->getArg();
$like = LinkFilter::makeLikeArray( $spec );
if ( !$like ) {
- $this->error( "Not a valid hostname specification: $spec", true );
+ $this->fatalError( "Not a valid hostname specification: $spec" );
}
if ( $this->hasOption( 'all' ) ) {
$page->doEditContent(
$content,
wfMessage( 'spam_reverting', $domain )->inContentLanguage()->text(),
- EDIT_UPDATE,
+ EDIT_UPDATE | EDIT_FORCE_BOT,
$rev->getId()
);
} elseif ( $this->hasOption( 'delete' ) ) {
$this->output( "blanking\n" );
$page->doEditContent(
$content,
- wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text()
+ wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text(),
+ EDIT_UPDATE | EDIT_FORCE_BOT
);
}
$this->commitTransaction( $dbw, __METHOD__ );
}
}
-$maintClass = "CleanupSpam";
+$maintClass = CleanupSpam::class;
require_once RUN_MAINTENANCE_IF_MAIN;