Allow cleanupSpam.php optionally delete offending pages
authorMax Semenik <maxsem.wiki@gmail.com>
Mon, 14 May 2012 19:24:31 +0000 (23:24 +0400)
committerMax Semenik <maxsem.wiki@gmail.com>
Wed, 13 Jun 2012 19:43:14 +0000 (23:43 +0400)
Change-Id: I69387df1b3d404a6d00d8073e58d7556c7ab9298

RELEASE-NOTES-1.20
languages/messages/MessagesEn.php
maintenance/cleanupSpam.php
maintenance/language/messages.inc

index dba0737..fefb686 100644 (file)
@@ -68,6 +68,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 4220) the XML dump format schema now have unique identity constraints
   for page and revision identifiers. Patch by Elvis Stansvik.
 * (bug 35705) QUnit upgraded from 1.2.0 to 1.7.0
+* cleanupSpam.php now can delete spam pages if --delete was specified instead of blanking
+  them.
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
index 1fdb65a..b7275f8 100644 (file)
@@ -3692,6 +3692,7 @@ This is probably caused by a link to a blacklisted external site.',
 'spambot_username'    => 'MediaWiki spam cleanup',
 'spam_reverting'      => 'Reverting to last revision not containing links to $1',
 'spam_blanking'       => 'All revisions contained links to $1, blanking',
+'spam_deleting'       => 'All revisions contained links to $1, deleting',
 
 # Info page
 'pageinfo-title'            => 'Information for "$1"',
index 8a760cd..f104899 100644 (file)
 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
 
 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() {
@@ -108,15 +110,19 @@ class CleanupSpam extends Maintenance {
                        $dbw = wfGetDB( DB_MASTER );
                        $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 ),
                                        EDIT_UPDATE, $rev->getId() );
+                       } elseif ( $this->hasOption( 'delete' ) ) {
+                               // Didn't find a non-spammy revision, blank the page
+                               $this->output( "deleting\n" );
+                               $page->doDeleteArticle( wfMsgForContent( 'spam_deleting', $domain ) );
+                       } else {
+                               // Didn't find a non-spammy revision, blank the page
+                               $this->output( "blanking\n" );
+                               $page->doEdit( '', wfMsgForContent( 'spam_blanking', $domain ) );
                        }
                        $dbw->commit( __METHOD__ );
                }
index 493fcc5..fbdef20 100644 (file)
@@ -2634,6 +2634,7 @@ $wgMessageStructure = array(
                'spambot_username',
                'spam_reverting',
                'spam_blanking',
+               'spam_deleting',
        ),
        'info' => array(
                'pageinfo-title',