From ab86aba0236ca96d58d75b839c003f093a12a297 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 25 Feb 2014 14:31:55 +0800 Subject: Bug 975943: add special support for a "deleted" comment tag --- contrib/sanitizeme.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'contrib') diff --git a/contrib/sanitizeme.pl b/contrib/sanitizeme.pl index 7033006dd..28c2f38f2 100755 --- a/contrib/sanitizeme.pl +++ b/contrib/sanitizeme.pl @@ -27,8 +27,10 @@ use strict; use lib qw(.); use Bugzilla; +use Bugzilla::Bug; use Bugzilla::Constants; use Bugzilla::Util; +use List::MoreUtils qw(uniq); use Getopt::Long; @@ -79,6 +81,7 @@ if ($dry_run) { eval { delete_non_public_products(); delete_secure_bugs(); + delete_deleted_comments(); delete_insider_comments() unless $keep_insider; delete_security_groups(); delete_sensitive_user_data(); @@ -129,6 +132,20 @@ sub delete_secure_bugs { print "\rDone \n" unless $from_cron; } +sub delete_deleted_comments { + # Delete all comments tagged as 'deleted' + my $comment_ids = $dbh->selectcol_arrayref("SELECT comment_id FROM longdescs_tags WHERE tag='deleted'"); + return unless @$comment_ids; + print "Deleting 'deleted' comments...\n"; + my @bug_ids = uniq @{ + $dbh->selectcol_arrayref("SELECT bug_id FROM longdescs WHERE comment_id IN (" . join(',', @$comment_ids) . ")") + }; + $dbh->do("DELETE FROM longdescs WHERE comment_id IN (" . join(',', @$comment_ids) . ")"); + foreach my $bug_id (@bug_ids) { + Bugzilla::Bug->new($bug_id)->_sync_fulltext(update_comments => 1); + } +} + sub delete_insider_comments { # Delete all 'insidergroup' comments and attachments print "Deleting 'insidergroup' comments and attachments...\n"; -- cgit v1.2.3-24-g4f1b