[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Update cleanupSpam.php to hide its activity from RecentChanges
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/379003 ) Change subject: Update cleanupSpam.php to hide its activity from RecentChanges .. 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 --- M maintenance/cleanupSpam.php 1 file changed, 6 insertions(+), 6 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 4e47cfb..fc3cc5b 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -49,10 +49,9 @@ 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 @@ $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 @@ $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__ ); -- To view, visit https://gerrit.wikimedia.org/r/379003 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifde08056a7481b877b4b82699cc0a5ea3f962dd9 Gerrit-PatchSet: 13 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MarcoAurelio Gerrit-Reviewer: Bartosz Dziewoński Gerrit-Reviewer: Krinkle Gerrit-Reviewer: Legoktm Gerrit-Reviewer: MacFan4000 Gerrit-Reviewer: MarcoAurelio Gerrit-Reviewer: MusikAnimal Gerrit-Reviewer: Parent5446 Gerrit-Reviewer: Reedy Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Update cleanupSpam.php to hide its activity from RecentChanges
MarcoAurelio has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/379003 ) Change subject: Update cleanupSpam.php to hide its activity from RecentChanges .. 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 cluttering Special:RecentChanges this patch makes the activities of the system account under which it operates the cleanupSpam.php maintenance script to be marked as 'bot' and removing them from RecentChanges It also switches from doDeleteArticle() to doDeleteArticleReal() to delete the pages with database consistency. 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. Change-Id: Ifde08056a7481b877b4b82699cc0a5ea3f962dd9 Co-Authored-by: Bartosz Dziewoński Bug: T176206 --- M maintenance/cleanupSpam.php 1 file changed, 9 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/03/379003/1 diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 4e47cfb..72095cf 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -131,14 +131,17 @@ $page->doEditContent( $content, wfMessage( 'spam_reverting', $domain )->inContentLanguage()->text(), - EDIT_UPDATE, + // Hide edit from RecentChanges and mark it as bot + EDIT_UPDATE | EDIT_FORCE_BOT | EDIT_SUPPRESS_RC, $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() + $page->doDeleteArticleReal( + wfMessage( 'spam_deleting', $domain )->inContentLanguage()->text(), + // Hide deletion from RecentChanges + EDIT_SUPPRESS_RC ); } else { // Didn't find a non-spammy revision, blank the page @@ -148,7 +151,9 @@ $this->output( "blanking\n" ); $page->doEditContent( $content, - wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text() + wfMessage( 'spam_blanking', $domain )->inContentLanguage()->text(), + // Hide edit from RecentChanges and mark it as bot as well + EDIT_UPDATE | EDIT_FORCE_BOT | EDIT_SUPPRESS_RC ); } $this->commitTransaction( $dbw, __METHOD__ ); -- To view, visit https://gerrit.wikimedia.org/r/379003 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifde08056a7481b877b4b82699cc0a5ea3f962dd9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MarcoAurelio ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits