summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Bug.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2006-06-08 06:35:53 +0200
committerlpsolit%gmail.com <>2006-06-08 06:35:53 +0200
commita609c6c3f0ac219b997dbaf4d1aaa6c7778c5939 (patch)
tree45e105fe9b2984c4169978872e94ac0703df6f13 /Bugzilla/Bug.pm
parent5711c06c6607dd46bae8c91c689a50d82f66fc2a (diff)
downloadbugzilla-a609c6c3f0ac219b997dbaf4d1aaa6c7778c5939.tar.gz
bugzilla-a609c6c3f0ac219b997dbaf4d1aaa6c7778c5939.tar.xz
Bug 339667: Attachment data not deleted when deleting a component or a product - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wicked a=justdave
Diffstat (limited to 'Bugzilla/Bug.pm')
-rwxr-xr-xBugzilla/Bug.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 185e50b44..810b1daf9 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -234,11 +234,15 @@ sub remove_from_db {
# - longdescs
# - votes
+ # Also, the attach_data table uses attachments.attach_id as a foreign
+ # key, and so indirectly depends on a bug deletion too.
+
$dbh->bz_lock_tables('attachments WRITE', 'bug_group_map WRITE',
'bugs WRITE', 'bugs_activity WRITE', 'cc WRITE',
'dependencies WRITE', 'duplicates WRITE',
'flags WRITE', 'keywords WRITE',
- 'longdescs WRITE', 'votes WRITE');
+ 'longdescs WRITE', 'votes WRITE',
+ 'attach_data WRITE');
$dbh->do("DELETE FROM bug_group_map WHERE bug_id = ?", undef, $bug_id);
$dbh->do("DELETE FROM bugs_activity WHERE bug_id = ?", undef, $bug_id);
@@ -251,6 +255,17 @@ sub remove_from_db {
$dbh->do("DELETE FROM keywords WHERE bug_id = ?", undef, $bug_id);
$dbh->do("DELETE FROM longdescs WHERE bug_id = ?", undef, $bug_id);
$dbh->do("DELETE FROM votes WHERE bug_id = ?", undef, $bug_id);
+
+ # The attach_data table doesn't depend on bugs.bug_id directly.
+ my $attach_ids =
+ $dbh->selectcol_arrayref("SELECT attach_id FROM attachments
+ WHERE bug_id = ?", undef, $bug_id);
+
+ if (scalar(@$attach_ids)) {
+ $dbh->do("DELETE FROM attach_data WHERE id IN (" .
+ join(",", @$attach_ids) . ")");
+ }
+
# Several of the previous tables also depend on attach_id.
$dbh->do("DELETE FROM attachments WHERE bug_id = ?", undef, $bug_id);
$dbh->do("DELETE FROM bugs WHERE bug_id = ?", undef, $bug_id);