From: MarcoAurelio Date: Tue, 19 Sep 2017 20:26:14 +0000 (+0200) Subject: Update cleanupSpam.php to hide its activity from RecentChanges X-Git-Tag: 1.31.0-rc.0~1926^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=7f842058602c2bb2358abb9e3228b156bd04fc7a Update cleanupSpam.php to hide its activity from RecentChanges Spam cleanup activities, mostly when it comes from automated processes (the so called 'spambots') can involve a fair ammount of edits and log actions to accomplish. As such, to avoid flooding Special:RecentChanges, this script will now set a bot flag on the script run so its edits and actions won't show up in that special page. To prepare this patch I had the help of Bartosz Dziewoński which I'd also like to thank and I'll credit as co-author as well. Bug: T176206 Co-Authored-By: Bartosz Dziewoński Change-Id: Ifde08056a7481b877b4b82699cc0a5ea3f962dd9 --- diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 4e47cfba57..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 ) { @@ -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__ );