r13427 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13426‎ | r13427 | r13428 >
Date:04:15, 2 April 2006
Author:brion
Status:old
Tags:
Comment:
Live fix: support running on all wikis on a farm site
Modified paths:
  • /trunk/phase3/maintenance/cleanupSpam.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/cleanupSpam.php
@@ -53,6 +53,9 @@
5454 }
5555 //------------------------------------------------------------------------------
5656
 57+
 58+
 59+
5760 $username = wfMsg( 'spambot_username' );
5861 $fname = $username;
5962 $wgUser = User::newFromName( $username );
@@ -74,15 +77,36 @@
7578
7679 $dbr =& wfGetDB( DB_SLAVE );
7780
78 -$res = $dbr->select( 'externallinks', array( 'el_from' ),
79 - array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname );
80 -$count = $dbr->numRows( $res );
81 -print "Found $count articles containing $spec\n";
82 -while ( $row = $dbr->fetchObject( $res ) ) {
83 - cleanupArticle( $row->el_from, $spec );
 81+if ( $options['all'] ) {
 82+ // Clean up spam on all wikis
 83+ $dbr =& wfGetDB( DB_SLAVE );
 84+ print "Finding spam on " . count($wgLocalDatabases) . " wikis\n";
 85+ $found = false;
 86+ foreach ( $wgLocalDatabases as $db ) {
 87+ $count = $dbr->selectField( "`$db`.externallinks", 'COUNT(*)',
 88+ array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname );
 89+ if ( $count ) {
 90+ $found = true;
 91+ passthru( "php cleanupSpam.php $db $spec | sed s/^/$db: /" );
 92+ }
 93+ }
 94+ if ( $found ) {
 95+ print "All done\n";
 96+ } else {
 97+ print "None found\n";
 98+ }
 99+} else {
 100+ // Clean up spam on this wiki
 101+ $res = $dbr->select( 'externallinks', array( 'DISTINCT el_from' ),
 102+ array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname );
 103+ $count = $dbr->numRows( $res );
 104+ print "Found $count articles containing $spec\n";
 105+ while ( $row = $dbr->fetchObject( $res ) ) {
 106+ cleanupArticle( $row->el_from, $spec );
 107+ }
 108+ if ( $count ) {
 109+ print "Done\n";
 110+ }
84111 }
85 -if ( $count ) {
86 - print "Done\n";
87 -}
88112
89113 ?>

Status & tagging log