From: lpsolit%gmail.com <> Date: Mon, 30 Jun 2008 02:52:49 +0000 (+0000) Subject: Bug 442517: Deleting a bug doesn't delete entries from custom multi-select fields... X-Git-Tag: bugzilla-3.2rc1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01ac3a358795ee167fbe188a80eb7e07f6c32d98;p=thirdparty%2Fbugzilla.git Bug 442517: Deleting a bug doesn't delete entries from custom multi-select fields - Patch by Frédéric Buclin r/a=mkanat --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index ec603e2b2a..d0eb69452a 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -778,6 +778,7 @@ sub remove_from_db { # - keywords # - longdescs # - votes + # Also included are custom multi-select fields. # Also, the attach_data table uses attachments.attach_id as a foreign # key, and so indirectly depends on a bug deletion too. @@ -810,6 +811,13 @@ sub remove_from_db { $dbh->do("DELETE FROM bugs WHERE bug_id = ?", undef, $bug_id); $dbh->do("DELETE FROM longdescs WHERE bug_id = ?", undef, $bug_id); + # Delete entries from custom multi-select fields. + my @multi_selects = Bugzilla->get_fields({custom => 1, type => FIELD_TYPE_MULTI_SELECT}); + + foreach my $field (@multi_selects) { + $dbh->do("DELETE FROM bug_" . $field->name . " WHERE bug_id = ?", undef, $bug_id); + } + $dbh->bz_commit_transaction(); # The bugs_fulltext table doesn't support transactions. diff --git a/sanitycheck.cgi b/sanitycheck.cgi index 93228fc67d..e32635970c 100755 --- a/sanitycheck.cgi +++ b/sanitycheck.cgi @@ -293,12 +293,17 @@ if ($cgi->param('remove_invalid_bug_references')) { $dbh->bz_start_transaction(); + # Include custom multi-select fields to the list. + my @multi_selects = Bugzilla->get_fields({custom => 1, type => FIELD_TYPE_MULTI_SELECT}); + my @addl_fields = map { 'bug_' . $_->name . '/' } @multi_selects; + foreach my $pair ('attachments/', 'bug_group_map/', 'bugs_activity/', 'bugs_fulltext/', 'cc/', 'dependencies/blocked', 'dependencies/dependson', 'duplicates/dupe', 'duplicates/dupe_of', - 'flags/', 'keywords/', 'longdescs/', 'votes/') { - + 'flags/', 'keywords/', 'longdescs/', 'votes/', + @addl_fields) + { my ($table, $field) = split('/', $pair); $field ||= "bug_id"; @@ -457,6 +462,10 @@ CrossCheck("flagtypes", "id", ["flagexclusions", "type_id"], ["flaginclusions", "type_id"]); +# Include custom multi-select fields to the list. +my @multi_selects = Bugzilla->get_fields({custom => 1, type => FIELD_TYPE_MULTI_SELECT}); +my @addl_fields = map { ['bug_' . $_->name, 'bug_id'] } @multi_selects; + CrossCheck("bugs", "bug_id", ["bugs_activity", "bug_id"], ["bug_group_map", "bug_id"], @@ -470,7 +479,8 @@ CrossCheck("bugs", "bug_id", ["votes", "bug_id"], ["keywords", "bug_id"], ["duplicates", "dupe_of", "dupe"], - ["duplicates", "dupe", "dupe_of"]); + ["duplicates", "dupe", "dupe_of"], + @addl_fields); CrossCheck("groups", "id", ["bug_group_map", "group_id"],