From f78955364bb90d95b295af690eb16a90ee5b9db8 Mon Sep 17 00:00:00 2001 From: "terry%mozilla.org" <> Date: Fri, 17 Dec 1999 11:41:12 +0000 Subject: Fixed very very nasty bug which, when deleting a component, would tell you it had no bugs (even when it had some), and would then proceed to delete all those bugs (even if you had the param set to never allow bug deletion.) Added some paranoia to prevent such things from happening again. Yikes. --- editcomponents.cgi | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'editcomponents.cgi') diff --git a/editcomponents.cgi b/editcomponents.cgi index 1c45a311a..2d7e9d81b 100755 --- a/editcomponents.cgi +++ b/editcomponents.cgi @@ -481,10 +481,9 @@ if ($action eq 'del') { print " Initial QA contact:\n"; print " $initialqacontact"; } - SendSQL("SELECT count(bug_id),product,component + SendSQL("SELECT count(bug_id) FROM bugs - GROUP BY product - HAVING product=" . SqlQuote($product) . " + WHERE product=" . SqlQuote($product) . " AND component=" . SqlQuote($component)); print "\n"; @@ -568,29 +567,34 @@ if ($action eq 'delete') { # so I have to iterate over bugs and delete all the indivial entries # in bugs_activies and attachments. - SendSQL("SELECT bug_id + if (Param("allowbugdeletion")) { + SendSQL("SELECT bug_id FROM bugs WHERE product=" . SqlQuote($product) . " AND component=" . SqlQuote($component)); - while (MoreSQLData()) { - my $bugid = FetchOneColumn(); + while (MoreSQLData()) { + my $bugid = FetchOneColumn(); - my $query = $::db->query("DELETE FROM attachments WHERE bug_id=$bugid") + my $query = + $::db->query("DELETE FROM attachments WHERE bug_id=$bugid") or die "$::db_errstr"; - $query = $::db->query("DELETE FROM bugs_activity WHERE bug_id=$bugid") + $query = + $::db->query("DELETE FROM bugs_activity WHERE bug_id=$bugid") or die "$::db_errstr"; - $query = $::db->query("DELETE FROM dependencies WHERE blocked=$bugid") + $query = + $::db->query("DELETE FROM dependencies WHERE blocked=$bugid") or die "$::db_errstr"; - } - print "Attachments, bug activity and dependencies deleted.
\n"; + } + print "Attachments, bug activity and dependencies deleted.
\n"; - # Deleting the rest is easier: + # Deleting the rest is easier: - SendSQL("DELETE FROM bugs + SendSQL("DELETE FROM bugs WHERE product=" . SqlQuote($product) . " AND component=" . SqlQuote($component)); - print "Bugs deleted.
\n"; + print "Bugs deleted.
\n"; + } SendSQL("DELETE FROM components WHERE program=" . SqlQuote($product) . " -- cgit v1.2.3-24-g4f1b