X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2FcleanupSpam.php;h=fc3cc5b8df094a21e33106d0e1bd12ed789eea74;hp=2f3f01347ca30b085f7fca7a28a64782efa3676d;hb=7f842058602c2bb2358abb9e3228b156bd04fc7a;hpb=c340c41b37b5079ba90489f6b212bb8e4642031a diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 2f3f01347c..fc3cc5b8df 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -49,10 +49,9 @@ class CleanupSpam extends Maintenance { if ( !$wgUser ) { $this->error( "Invalid username specified in 'spambot_username' message: $username", true ); } - // Create the user if necessary - if ( !$wgUser->getId() ) { - $wgUser->addToDatabase(); - } + // Hack: Grant bot rights so we don't flood RecentChanges + $wgUser->addGroup( 'bot' ); + $spec = $this->getArg(); $like = LinkFilter::makeLikeArray( $spec ); if ( !$like ) { @@ -64,7 +63,7 @@ class CleanupSpam extends Maintenance { $this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" ); $found = false; foreach ( $wgLocalDatabases as $wikiID ) { - $dbr = $this->getDB( DB_SLAVE, [], $wikiID ); + $dbr = $this->getDB( DB_REPLICA, [], $wikiID ); $count = $dbr->selectField( 'externallinks', 'COUNT(*)', [ 'el_index' . $dbr->buildLike( $like ) ], __METHOD__ ); @@ -83,7 +82,7 @@ class CleanupSpam extends Maintenance { } else { // Clean up spam on this wiki - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $res = $dbr->select( 'externallinks', [ 'DISTINCT el_from' ], [ 'el_index' . $dbr->buildLike( $like ) ], __METHOD__ ); $count = $dbr->numRows( $res ); @@ -131,7 +130,7 @@ class CleanupSpam extends Maintenance { $page->doEditContent( $content, wfMessage( 'spam_reverting', $domain )->inContentLanguage()->text(), - EDIT_UPDATE, + EDIT_UPDATE | EDIT_FORCE_BOT, $rev->getId() ); } elseif ( $this->hasOption( 'delete' ) ) { @@ -148,7 +147,8 @@ class CleanupSpam extends Maintenance { $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__ );