summaryrefslogtreecommitdiff
path: root/maintenance/cleanupSpam.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /maintenance/cleanupSpam.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'maintenance/cleanupSpam.php')
-rw-r--r--maintenance/cleanupSpam.php35
1 files changed, 23 insertions, 12 deletions
diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php
index ca1e302b..e20bcd87 100644
--- a/maintenance/cleanupSpam.php
+++ b/maintenance/cleanupSpam.php
@@ -1,6 +1,6 @@
<?php
/**
- * Cleanup all spam from a given hostname
+ * Cleanup all spam from a given hostname.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,20 +21,27 @@
* @ingroup Maintenance
*/
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+require_once( __DIR__ . '/Maintenance.php' );
+/**
+ * Maintenance script to cleanup all spam from a given hostname.
+ *
+ * @ingroup Maintenance
+ */
class CleanupSpam extends Maintenance {
+
public function __construct() {
parent::__construct();
$this->mDescription = "Cleanup all spam from a given hostname";
$this->addOption( 'all', 'Check all wikis in $wgLocalDatabases' );
- $this->addArg( 'hostname', 'Hostname that was spamming' );
+ $this->addOption( 'delete', 'Delete pages containing only spam instead of blanking them' );
+ $this->addArg( 'hostname', 'Hostname that was spamming, single * wildcard in the beginning allowed' );
}
public function execute() {
global $wgLocalDatabases, $wgUser;
- $username = wfMsg( 'spambot_username' );
+ $username = wfMessage( 'spambot_username' )->text();
$wgUser = User::newFromName( $username );
if ( !$wgUser ) {
$this->error( "Invalid username", true );
@@ -106,19 +113,23 @@ class CleanupSpam extends Maintenance {
$this->output( "False match\n" );
} else {
$dbw = wfGetDB( DB_MASTER );
- $dbw->begin();
+ $dbw->begin( __METHOD__ );
$page = WikiPage::factory( $title );
- if ( !$rev ) {
- // Didn't find a non-spammy revision, blank the page
- $this->output( "blanking\n" );
- $page->doEdit( '', wfMsgForContent( 'spam_blanking', $domain ) );
- } else {
+ if ( $rev ) {
// Revert to this revision
$this->output( "reverting\n" );
- $page->doEdit( $rev->getText(), wfMsgForContent( 'spam_reverting', $domain ),
+ $page->doEdit( $rev->getText(), wfMessage( 'spam_reverting', $domain )->inContentLanguage()->text(),
EDIT_UPDATE, $rev->getId() );
+ } elseif ( $this->hasOption( 'delete' ) ) {
+ // Didn't find a non-spammy revision, blank the page
+ $this->output( "deleting\n" );
+ $page->doDeleteArticle( wfMessage( 'spam_deleting', $domain )->inContentLanguage()->text() );
+ } else {
+ // Didn't find a non-spammy revision, blank the page
+ $this->output( "blanking\n" );
+ $page->doEdit( '', wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text() );
}
- $dbw->commit();
+ $dbw->commit( __METHOD__ );
}
}
}