]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 442517: Deleting a bug doesn't delete entries from custom multi-select fields...
authorlpsolit%gmail.com <>
Mon, 30 Jun 2008 02:52:49 +0000 (02:52 +0000)
committerlpsolit%gmail.com <>
Mon, 30 Jun 2008 02:52:49 +0000 (02:52 +0000)
Bugzilla/Bug.pm
sanitycheck.cgi

index ec603e2b2a4fbd901fb6f04842522d9c4acd4236..d0eb69452ad46f0ea4ac9fb9b9bf527e7264df98 100644 (file)
@@ -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.
index 93228fc67dd03e5134e1ddd3b3428487e235c167..e32635970cea6488f4357a7b7050adf5ef3acab1 100755 (executable)
@@ -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"],