]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 86328: Deleting bugs doesn't delete dependent records properly - Patch by Frederi...
authorlpsolit%gmail.com <>
Wed, 6 Apr 2005 07:19:51 +0000 (07:19 +0000)
committerlpsolit%gmail.com <>
Wed, 6 Apr 2005 07:19:51 +0000 (07:19 +0000)
12 files changed:
Bugzilla/Bug.pm
editcomponents.cgi
editmilestones.cgi
editproducts.cgi
editversions.cgi
template/en/default/admin/components/deleted.html.tmpl
template/en/default/admin/milestones/confirm-delete.html.tmpl
template/en/default/admin/milestones/deleted.html.tmpl
template/en/default/admin/versions/confirm-delete.html.tmpl
template/en/default/admin/versions/deleted.html.tmpl
template/en/default/filterexceptions.pl
template/en/default/global/user-error.html.tmpl

index 87bf96e2526571aada20dca76b64968a578ab814..5017196b3d599fe5c269edb95dcc248705ff4454 100755 (executable)
@@ -23,6 +23,7 @@
 #                 Bradley Baetz  <bbaetz@acm.org>
 #                 Dave Miller    <justdave@bugzilla.org>
 #                 Max Kanat-Alexander <mkanat@kerio.com>
+#                 Frédéric Buclin <LpSolit@gmail.com>
 
 package Bugzilla::Bug;
 
@@ -217,6 +218,60 @@ sub initBug  {
   return $self;
 }
 
+# This is the correct way to delete bugs from the DB.
+# No bug should be deleted from anywhere else except from here.
+#
+sub remove_from_db {
+    my ($self) = @_;
+    my $dbh = Bugzilla->dbh;
+
+    if ($self->{'error'}) {
+        ThrowCodeError("bug_error", { bug => $self });
+    }
+
+    my $bug_id = $self->{'bug_id'};
+
+    # tables having 'bugs.bug_id' as a foreign key:
+    # - attachments
+    # - bug_group_map
+    # - bugs
+    # - bugs_activity
+    # - cc
+    # - dependencies
+    # - duplicates
+    # - flags
+    # - keywords
+    # - longdescs
+    # - votes
+
+    $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');
+
+    $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);
+    $dbh->do("DELETE FROM cc WHERE bug_id = ?", undef, $bug_id);
+    $dbh->do("DELETE FROM dependencies WHERE blocked = ? OR dependson = ?",
+             undef, ($bug_id, $bug_id));
+    $dbh->do("DELETE FROM duplicates WHERE dupe = ? OR dupe_of = ?",
+             undef, ($bug_id, $bug_id));
+    $dbh->do("DELETE FROM flags WHERE bug_id = ?", undef, $bug_id);
+    $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);
+    # 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);
+
+    $dbh->bz_unlock_tables();
+
+    # Now this bug no longer exists
+    $self->DESTROY;
+    return $self;
+}
+
 #####################################################################
 # Accessors
 #####################################################################
index 9dd290db35022f8d0012e2b0f0bcb66e5a27563b..6f8bc99f22efad1b068ab48f2b44a6ce9a62eaf5 100755 (executable)
@@ -112,7 +112,8 @@ sub CheckComponent ($$)
 # Preliminary checks:
 #
 
-Bugzilla->login(LOGIN_REQUIRED);
+my $user = Bugzilla->login(LOGIN_REQUIRED);
+my $whoid = $user->id;
 
 print Bugzilla->cgi->header();
 
@@ -436,57 +437,36 @@ if ($action eq 'del') {
 #
 
 if ($action eq 'delete') {
-
     CheckComponent($product, $component);
-    my $component_id = get_component_id(get_product_id($product),$component);
-
-    # lock the tables before we start to change everything:
-
-    $dbh->bz_lock_tables('attachments WRITE',
-                         'bugs WRITE',
-                         'bugs_activity WRITE',
-                         'components WRITE',
-                         'dependencies WRITE',
-                         'flaginclusions WRITE',
-                         'flagexclusions WRITE');
-
-    # According to MySQL doc I cannot do a DELETE x.* FROM x JOIN Y,
-    # so I have to iterate over bugs and delete all the indivial entries
-    # in bugs_activies and attachments.
-
-    if (Param("allowbugdeletion")) {
-        my $deleted_bug_count = 0;
-
-        SendSQL("SELECT bug_id
-                 FROM bugs
-                 WHERE component_id = $component_id");
-        while (MoreSQLData()) {
-            my $bugid = FetchOneColumn();
-
-            PushGlobalSQLState();
-            SendSQL("DELETE FROM attachments WHERE bug_id=$bugid");
-            SendSQL("DELETE FROM bugs_activity WHERE bug_id=$bugid");
-            SendSQL("DELETE FROM dependencies WHERE blocked=$bugid");
-            PopGlobalSQLState();
+    my $component_id = get_component_id(get_product_id($product), $component);
 
-            $deleted_bug_count++;
+    my $bug_ids =
+      $dbh->selectcol_arrayref("SELECT bug_id FROM bugs WHERE component_id = ?",
+                               undef, $component_id);
+
+    my $nb_bugs = scalar(@$bug_ids);
+    if ($nb_bugs) {
+        if (Param("allowbugdeletion")) {
+            foreach my $bug_id (@$bug_ids) {
+                my $bug = new Bugzilla::Bug($bug_id, $whoid);
+                $bug->remove_from_db();
+            }
         }
+        else {
+            ThrowUserError("component_has_bugs", { nb => $nb_bugs });
+        }
+    }
 
-        $vars->{'deleted_bug_count'} = $deleted_bug_count;
-
-        # Deleting the rest is easier:
+    $vars->{'deleted_bug_count'} = $nb_bugs;
 
-        SendSQL("DELETE FROM bugs
-                 WHERE component_id=$component_id");
-    }
+    $dbh->bz_lock_tables('components WRITE', 'flaginclusions WRITE',
+                         'flagexclusions WRITE');
 
-    SendSQL("DELETE FROM flaginclusions
-             WHERE component_id=$component_id");
-    SendSQL("DELETE FROM flagexclusions
-             WHERE component_id=$component_id");
-    
-    SendSQL("DELETE FROM components
-             WHERE id=$component_id");
+    $dbh->do("DELETE FROM flaginclusions WHERE component_id = ?",
+             undef, $component_id);
+    $dbh->do("DELETE FROM flagexclusions WHERE component_id = ?",
+             undef, $component_id);
+    $dbh->do("DELETE FROM components WHERE id = ?", undef, $component_id);
 
     $dbh->bz_unlock_tables();
 
@@ -494,10 +474,8 @@ if ($action eq 'delete') {
 
     $vars->{'name'} = $component;
     $vars->{'product'} = $product;
-    $template->process("admin/components/deleted.html.tmpl",
-                       $vars)
+    $template->process("admin/components/deleted.html.tmpl", $vars)
       || ThrowTemplateError($template->error());
-
     exit;
 }
 
index 796643e9e2f7e885d6b2c991c1b41d3f27d52266..5c9e214689df07a1bbd62ff2f1b2cf6e83cc22a4 100755 (executable)
@@ -12,6 +12,7 @@
 # Matt Masson <matthew@zeroknowledge.com>
 #
 # Contributors : Gavin Shelley <bugzilla@chimpychompy.org>
+#                Frédéric Buclin <LpSolit@gmail.com>
 #
 
 
@@ -119,7 +120,8 @@ sub CheckMilestone ($$)
 # Preliminary checks:
 #
 
-Bugzilla->login(LOGIN_REQUIRED);
+my $user = Bugzilla->login(LOGIN_REQUIRED);
+my $whoid = $user->id;
 
 print Bugzilla->cgi->header();
 
@@ -304,39 +306,31 @@ if ($action eq 'new') {
 #
 
 if ($action eq 'del') {
-
     CheckMilestone($product, $milestone);
     my $product_id = get_product_id($product);
-
     my $dbh = Bugzilla->dbh;
 
-    my $sth = $dbh->prepare('SELECT count(bug_id), product_id, target_milestone
-                             FROM bugs ' .
-                            $dbh->sql_group_by('product_id,
-                                                target_milestone') . '
-                             HAVING product_id = ?
-                                AND target_milestone = ?');
+    $vars->{'default_milestone'} =
+      $dbh->selectrow_array('SELECT defaultmilestone
+                             FROM products WHERE id = ?',
+                             undef, $product_id);
 
     trick_taint($milestone);
-    $vars->{'bug_count'} = $dbh->selectrow_array($sth,
-                                                 undef,
-                                                 $product_id,
-                                                 $milestone) || 0;
+    $vars->{'name'} = $milestone;
+    $vars->{'product'} = $product;
 
-    $sth = $dbh->prepare('SELECT defaultmilestone
-                          FROM products
-                          WHERE id = ?');
+    # The default milestone cannot be deleted.
+    if ($vars->{'default_milestone'} eq $milestone) {
+        ThrowUserError("milestone_is_default", $vars);
+    }
 
-    $vars->{'default_milestone'} = $dbh->selectrow_array($sth,
-                                                         undef,
-                                                         $product_id) || '';
+    $vars->{'bug_count'} =
+      $dbh->selectrow_array("SELECT COUNT(bug_id) FROM bugs
+                             WHERE product_id = ? AND target_milestone = ?",
+                             undef, ($product_id, $milestone)) || 0;
 
-    $vars->{'name'} = $milestone;
-    $vars->{'product'} = $product;
-    $template->process("admin/milestones/confirm-delete.html.tmpl",
-                       $vars)
+    $template->process("admin/milestones/confirm-delete.html.tmpl", $vars)
       || ThrowTemplateError($template->error());
-
     exit;
 }
 
@@ -347,88 +341,52 @@ if ($action eq 'del') {
 #
 
 if ($action eq 'delete') {
-
-    CheckMilestone($product,$milestone);
+    CheckMilestone($product, $milestone);
     my $product_id = get_product_id($product);
-
     my $dbh = Bugzilla->dbh;
 
-    # lock the tables before we start to change everything:
-
-    $dbh->bz_lock_tables('attachments WRITE',
-                         'bugs WRITE',
-                         'bugs_activity WRITE',
-                         'milestones WRITE',
-                         'dependencies WRITE');
-
-    # According to MySQL doc I cannot do a DELETE x.* FROM x JOIN Y,
-    # so I have to iterate over bugs and delete all the indivial entries
-    # in bugs_activies and attachments.
+    my $default_milestone =
+      $dbh->selectrow_array("SELECT defaultmilestone
+                             FROM products WHERE id = ?",
+                             undef, $product_id);
 
-    # Detaint this here, as we may need it if deleting bugs, but will
-    # definitely need it detainted whhen we actually delete the
-    # milestone itself
     trick_taint($milestone);
+    $vars->{'name'} = $milestone;
+    $vars->{'product'} = $product;
 
-    if (Param("allowbugdeletion")) {
-
-        my $deleted_bug_count = 0;
-
-        my $sth = $dbh->prepare_cached('SELECT bug_id
-                                        FROM bugs
-                                        WHERE product_id = ?
-                                        AND target_milestone = ?');
-
-        my $data = $dbh->selectall_arrayref($sth,
-                                            undef,
-                                            $product_id,
-                                            $milestone);
-
-        foreach my $aref (@$data) {
-
-            my ($bugid) = @$aref;
-
-            $dbh->do('DELETE FROM attachments WHERE bug_id = ?',
-                     undef,
-                     $bugid);
-            $dbh->do('DELETE FROM bugs_activity WHERE bug_id = ?',
-                     undef,
-                     $bugid);
-            $dbh->do('DELETE FROM dependencies WHERE blocked = ?',
-                     undef,
-                     $bugid);
+    # The default milestone cannot be deleted.
+    if ($milestone eq $default_milestone) {
+        ThrowUserError("milestone_is_default", $vars);
+    }
 
-            $deleted_bug_count++;
+    # We don't want to delete bugs when deleting a milestone.
+    # Bugs concerned are reassigned to the default milestone.
+    my $bug_ids =
+      $dbh->selectcol_arrayref("SELECT bug_id FROM bugs
+                                WHERE product_id = ? AND target_milestone = ?",
+                                undef, ($product_id, $milestone));
+
+    my $nb_bugs = scalar(@$bug_ids);
+    if ($nb_bugs) {
+        my $timestamp = $dbh->selectrow_array("SELECT NOW()");
+        foreach my $bug_id (@$bug_ids) {
+            $dbh->do("UPDATE bugs SET target_milestone = ?,
+                      delta_ts = ? WHERE bug_id = ?",
+                      undef, ($default_milestone, $timestamp, $bug_id));
+            # We have to update the 'bugs_activity' table too.
+            LogActivityEntry($bug_id, 'target_milestone', $milestone,
+                             $default_milestone, $whoid, $timestamp);
         }
-
-        $vars->{'deleted_bug_count'} = $deleted_bug_count;
-
-        # Deleting the rest is easier:
-
-        $dbh->do('DELETE FROM bugs
-                  WHERE product_id = ?
-                  AND target_milestone = ?',
-                 undef,
-                 $product_id,
-                 $milestone);
     }
 
-    $dbh->do('DELETE FROM milestones
-              WHERE product_id = ?
-              AND value = ?',
-             undef,
-             $product_id,
-             $milestone);
+    $vars->{'bug_count'} = $nb_bugs;
 
-    $dbh->bz_unlock_tables();
+    $dbh->do("DELETE FROM milestones WHERE product_id = ? AND value = ?",
+             undef, ($product_id, $milestone));
 
     unlink "$datadir/versioncache";
 
-
-    $vars->{'name'} = $milestone;
-    $vars->{'product'} = $product;
-    $template->process("admin/milestones/deleted.html.tmpl",
-                       $vars)
+    $template->process("admin/milestones/deleted.html.tmpl", $vars)
       || ThrowTemplateError($template->error());
     exit;
 }
index 2267de922248038125d093c2a833bd59ce0c423f..4713a45ae7fe2958d0da7e6cb9c708d1848f6564 100755 (executable)
@@ -23,6 +23,7 @@
 #               Dawn Endico <endico@mozilla.org>
 #               Joe Robins <jmrobins@tgix.com>
 #               Gavin Shelley <bugzilla@chimpychompy.org>
+#               Frédéric Buclin <LpSolit@gmail.com>
 #
 # Direct any questions on this source code to
 #
@@ -259,7 +260,8 @@ sub PutTrailer (@)
 # Preliminary checks:
 #
 
-Bugzilla->login(LOGIN_REQUIRED);
+my $user = Bugzilla->login(LOGIN_REQUIRED);
+my $whoid = $user->id;
 
 print Bugzilla->cgi->header();
 
@@ -771,79 +773,55 @@ one.";
 #
 
 if ($action eq 'delete') {
-    PutHeader("Deleting product");
     CheckProduct($product);
     my $product_id = get_product_id($product);
 
-    # lock the tables before we start to change everything:
-
-    $dbh->bz_lock_tables('attachments WRITE',
-                         'bugs WRITE',
-                         'bugs_activity WRITE',
-                         'components WRITE',
-                         'dependencies WRITE',
-                         'versions WRITE',
-                         'products WRITE',
-                         'groups WRITE',
-                         'group_control_map WRITE',
-                         'profiles WRITE',
-                         'milestones WRITE',
-                         'flaginclusions WRITE',
-                         'flagexclusions WRITE');
-
-    # According to MySQL doc I cannot do a DELETE x.* FROM x JOIN Y,
-    # so I have to iterate over bugs and delete all the indivial entries
-    # in bugs_activies and attachments.
-
-    if (Param("allowbugdeletion")) {
-        SendSQL("SELECT bug_id
-             FROM bugs
-             WHERE product_id=$product_id");
-        while (MoreSQLData()) {
-            my $bugid = FetchOneColumn();
+    my $bug_ids =
+      $dbh->selectcol_arrayref("SELECT bug_id FROM bugs WHERE product_id = ?",
+                               undef, $product_id);
 
-            PushGlobalSQLState();
-            SendSQL("DELETE FROM attachments WHERE bug_id=$bugid");
-            SendSQL("DELETE FROM bugs_activity WHERE bug_id=$bugid");
-            SendSQL("DELETE FROM dependencies WHERE blocked=$bugid");
-            PopGlobalSQLState();
+    my $nb_bugs = scalar(@$bug_ids);
+    if ($nb_bugs) {
+        if (Param("allowbugdeletion")) {
+            foreach my $bug_id (@$bug_ids) {
+                my $bug = new Bugzilla::Bug($bug_id, $whoid);
+                $bug->remove_from_db();
+            }
         }
-        print "Attachments, bug activity and dependencies deleted.<BR>\n";
-
+        else {
+            ThrowUserError("product_has_bugs", { nb => $nb_bugs });
+        }
+    }
 
-        # Deleting the rest is easier:
+    PutHeader("Deleting product");
+    print "All references to deleted bugs removed.<P>\n" if $nb_bugs;
 
-        SendSQL("DELETE FROM bugs
-             WHERE product_id=$product_id");
-        print "Bugs deleted.<BR>\n";
-    }
+    $dbh->bz_lock_tables('products WRITE', 'components WRITE',
+                         'versions WRITE', 'milestones WRITE',
+                         'group_control_map WRITE',
+                         'flaginclusions WRITE', 'flagexclusions WRITE');
 
-    SendSQL("DELETE FROM components
-             WHERE product_id=$product_id");
+    $dbh->do("DELETE FROM components WHERE product_id = ?", undef, $product_id);
     print "Components deleted.<BR>\n";
 
-    SendSQL("DELETE FROM versions
-             WHERE product_id=$product_id");
-    print "Versions deleted.<P>\n";
+    $dbh->do("DELETE FROM versions WHERE product_id = ?", undef, $product_id);
+    print "Versions deleted.<BR>\n";
 
-    # deleting associated target milestones - matthew@zeroknowledge.com
-    SendSQL("DELETE FROM milestones
-             WHERE product_id=$product_id");
-    print "Milestones deleted.<BR>\n";
+    $dbh->do("DELETE FROM milestones WHERE product_id = ?", undef, $product_id);
+    print "Milestones deleted.<P>\n";
 
-    SendSQL("DELETE FROM group_control_map
-             WHERE product_id=$product_id");
+    $dbh->do("DELETE FROM group_control_map WHERE product_id = ?",
+             undef, $product_id);
     print "Group controls deleted.<BR>\n";
 
-    SendSQL("DELETE FROM flaginclusions
-             WHERE product_id=$product_id");
-    SendSQL("DELETE FROM flagexclusions
-             WHERE product_id=$product_id");
-    print "Flag inclusions and exclusions deleted.<BR>\n";
+    $dbh->do("DELETE FROM flaginclusions WHERE product_id = ?",
+             undef, $product_id);
+    $dbh->do("DELETE FROM flagexclusions WHERE product_id = ?",
+             undef, $product_id);
+    print "Flag inclusions and exclusions deleted.<P>\n";
 
-    SendSQL("DELETE FROM products
-             WHERE id=$product_id");
-    print "Product '$product' deleted.<BR>\n";
+    $dbh->do("DELETE FROM products WHERE id = ?", undef, $product_id);
+    print "Product '$product' deleted.<P>\n";
 
     $dbh->bz_unlock_tables();
 
index 86c82beea395b312094863cdf06afb7c1427ec7b..8d3f4dc8b6c110fa64e8715fe0683fd057408023 100755 (executable)
@@ -21,6 +21,7 @@
 # Contributor(s): Holger Schurig <holgerschurig@nikocity.de>
 #                 Terry Weissman <terry@mozilla.org>
 #                 Gavin Shelley <bugzilla@chimpychompy.org>
+#                 Frédéric Buclin <LpSolit@gmail.com>
 #
 #
 # Direct any questions on this source code to
@@ -293,66 +294,32 @@ if ($action eq 'del') {
 #
 
 if ($action eq 'delete') {
-
-    CheckVersion($product,$version);
+    CheckVersion($product, $version);
     my $product_id = get_product_id($product);
 
-    # lock the tables before we start to change everything:
-
-    $dbh->bz_lock_tables('attachments WRITE',
-                         'bugs WRITE',
-                         'bugs_activity WRITE',
-                         'versions WRITE',
-                         'dependencies WRITE');
-
-    # According to MySQL doc I cannot do a DELETE x.* FROM x JOIN Y,
-    # so I have to iterate over bugs and delete all the indivial entries
-    # in bugs_activies and attachments.
+    trick_taint($version);
 
-    if (Param("allowbugdeletion")) {
-
-        my $deleted_bug_count = 0;
-
-        SendSQL("SELECT bug_id
-                 FROM bugs
-                 WHERE product_id = $product_id
-                   AND version = " . SqlQuote($version));
-        while (MoreSQLData()) {
-            my $bugid = FetchOneColumn();
-
-            PushGlobalSQLState();
-            SendSQL("DELETE FROM attachments WHERE bug_id = $bugid");
-            SendSQL("DELETE FROM bugs_activity WHERE bug_id = $bugid");
-            SendSQL("DELETE FROM dependencies WHERE blocked = $bugid");
-            PopGlobalSQLState();
-
-            $deleted_bug_count++;
-        }
-
-        $vars->{'deleted_bug_count'} = $deleted_bug_count;
-
-        # Deleting the rest is easier:
-
-        SendSQL("DELETE FROM bugs
-                 WHERE product_id = $product_id
-                   AND version = " . SqlQuote($version));
+    my $nb_bugs =
+      $dbh->selectrow_array("SELECT COUNT(bug_id) FROM bugs
+                             WHERE product_id = ? AND version = ?",
+                             undef, ($product_id, $version));
 
+    # The version cannot be removed if there are bugs
+    # associated with it.
+    if ($nb_bugs) {
+        ThrowUserError("version_has_bugs", { nb => $nb_bugs });
     }
 
-    SendSQL("DELETE FROM versions
-             WHERE product_id = $product_id
-               AND value = " . SqlQuote($version));
-
-    $dbh->bz_unlock_tables();
+    $dbh->do("DELETE FROM versions WHERE product_id = ? AND value = ?",
+              undef, ($product_id, $version));
 
     unlink "$datadir/versioncache";
 
     $vars->{'name'} = $version;
     $vars->{'product'} = $product;
-    $template->process("admin/versions/deleted.html.tmpl",
-                       $vars)
-      || ThrowTemplateError($template->error());
 
+    $template->process("admin/versions/deleted.html.tmpl", $vars)
+      || ThrowTemplateError($template->error());
     exit;
 }
 
index 6efa388433850ff3ea96ef398fa03d516bf0d0cc..83c0068693295317b8c6fc14dc064cf7080bbe5f 100644 (file)
 
 <p>
 [% IF deleted_bug_count %]
-  Attachments, [% terms.bug %] activity and dependencies deleted for
-  [%+ deleted_bug_count %]
-  [%- IF deleted_bug_count %] 
-    [% terms.bugs %]
-  [% ELSE %]
-    [% terms.bug %]
-  [% END %].
-
-  </p><p>
   [% deleted_bug_count %]
-  [%- IF deleted_bug_count %] 
+  [%- IF deleted_bug_count > 1 %] 
     [% terms.bugs %]
   [% ELSE %]
     [% terms.bug %]
   [% END %]
   deleted.
-
+  </p><p>
+  All references to those deleted [% terms.bugs %] have been removed.
 [% ELSE %]
   No [% terms.bugs %] existed for the component.
 [% END %]
index 893b849ae2eb755e57dd094390c28a9c531cdbcc..c3d379cbd58ea61a9c01510e73a4d84349dcf31d 100644 (file)
@@ -17,6 +17,7 @@
   # Rights Reserved.
   #
   # Contributor(s): Gavin Shelley <bugzilla@chimpychompy.org>
+  #                 Frédéric Buclin <LpSolit@gmail.com>
   #%]
 
 [%# INTERFACE:
   
 [% IF bug_count %]
 
-  [% IF !Param("allowbugdeletion") %]
-
-    Sorry, there
-
+  <table border="0" cellpadding="20" width="70%" bgcolor="red">
+  <tr><td>
+    There
     [% IF bug_count > 1 %] 
       are [% bug_count %] [%+ terms.bugs %] 
     [% ELSE %]
-      is [% bug_count %] [%+ terms.bug %] 
-    [% END %]
-
-    outstanding for this milestone. You must move 
-
-    [% IF bug_count > 1 %]
-       those [% terms.bugs %] 
-    [% ELSE %]
-       that [% terms.bug %]
+      is 1 [% terms.bug %]
     [% END %]
-
-    to another milestone before you can delete this one.
-
-  [% ELSE %]
-
-    <table border="0" cellpadding="20" width="70%" bgcolor="red"><tr><td>
-
-      There [% IF bug_count > 1 %] 
-        are [% bug_count %] [%+ terms.bugs %] 
-      [% ELSE %]
-        is 1 [% terms.bug %]
-      [% END %]
-      entered for this milestone!  When you delete this
-      milestone, <b><blink>ALL</blink></b> stored [% terms.bugs %] will be deleted,
-      too.
-      You could not even see the [% terms.bug %] history for this milestone anymore!
-      </td></tr></table>
-
-  [% END %]
+    entered for this milestone! When you delete this milestone,
+    <b><blink>ALL</blink></b> stored [% terms.bugs %] will be reassigned to
+    the default milestone of this product.
+  </td></tr>
+  </table>
 
 [% END %]
 
-[% IF default_milestone == name %]
-
-    <p>Sorry, but '[% name FILTER html %]' is the default milestone for product '
-    [%- product FILTER html %]', and so it can not be deleted.
-
-  [% ELSE %]
-
-    [% IF bug_count == 0 || Param('allowbugdeletion') %]
+<p>Do you really want to delete this milestone?<p>
 
-      <p>Do you really want to delete this milestone?<p>
-  
-      <form method="post" action="editmilestones.cgi">
-        <input type="submit" value="Yes, delete">
-        <input type="hidden" name="action" value="delete">
-        <input type="hidden" name="product" value="[% product FILTER html %]">
-        <input type="hidden" name="milestone" value="[% name FILTER html %]">
-      </form>
-
-  [% END %]
-
-[% END %]
+<form method="post" action="editmilestones.cgi">
+  <input type="submit" value="Yes, delete">
+  <input type="hidden" name="action" value="delete">
+  <input type="hidden" name="product" value="[% product FILTER html %]">
+  <input type="hidden" name="milestone" value="[% name FILTER html %]">
+</form>
 
 [% PROCESS admin/milestones/footer.html.tmpl %]
 
index 61abb38e5870db00cb10c562e3d18fb781f31f19..3a3e52ab56c29dfce3bf81de032caa6b15d737a0 100644 (file)
@@ -17,6 +17,7 @@
   # Rights Reserved.
   #
   # Contributor(s): Gavin Shelley <bugzilla@chimpychompy.org>
+  #                 Frédéric Buclin <LpSolit@gmail.com>
   #%]
 
 [%# INTERFACE:
@@ -24,8 +25,8 @@
   #
   # product: string; the name of the product the milestone belonged to
   #
-  # deleted_bug_count: number; the number of bugs which were deleted
-  #                            (if bug deletion is allowed)
+  # bug_count: number; the number of bugs which were reassigned to
+  #            the default milestone.
   #%]
   
 [% title = BLOCK %]Deleted Milestone '[% name FILTER html %]' of Product
 %]
 
 <p>
-[% IF deleted_bug_count %]
-  Attachments, [% terms.bug %] activity and dependencies deleted for
-  [%+ deleted_bug_count %]
-  [% IF deleted_bug_count > 1 %] 
-    [%+ terms.bugs %]
-  [% ELSE %]
-    [%+ terms.bug %]
-  [% END %].
+[% IF bug_count %]
 
-  </p><p>
-  [% deleted_bug_count %]
-  [% IF deleted_bug_count > 1 %] 
+  [% bug_count %]
+  [% IF bug_count > 1 %] 
     [%+ terms.bugs %]
   [% ELSE %]
     [%+ terms.bug %]
   [% END %]
-  deleted.
+  reassigned to the default milestone.
 
 [% ELSE %]
   No [% terms.bugs %] were targetted at the milestone.
index 5f9b9394309d80f3eed45f4c24c60be4f09ba429..acc20aecacc0247698a545fd4f6bae46ce64bfd0 100644 (file)
@@ -17,6 +17,7 @@
   # Rights Reserved.
   #
   # Contributor(s): Gavin Shelley <bugzilla@chimpychompy.org>
+  #                 Frédéric Buclin <LpSolit@gmail.com>
   #%]
 
 [%# INTERFACE:
   
 [% IF bug_count %]
 
-  [% IF !Param("allowbugdeletion") %]
-
-    Sorry, there
-
-    [% IF bug_count > 1 %] 
-      are [% bug_count %] [%+ terms.bugs %] 
-    [% ELSE %]
-      is [% bug_count %] [%+ terms.bug %] 
-    [% END %]
-
-    outstanding for this version. You must move 
-
-    [% IF bug_count > 1 %]
-       those [% terms.bugs %] 
-    [% ELSE %]
-       that [% terms.bug %]
-    [% END %]
-
-    to another version before you can delete this one.
-
+  Sorry, there
+  [% IF bug_count > 1 %] 
+    are [% bug_count %] [%+ terms.bugs %] 
   [% ELSE %]
+    is [% bug_count %] [%+ terms.bug %] 
+  [% END %]
 
-    <table border="0" cellpadding="20" width="70%" bgcolor="red"><tr><td>
-
-      There [% IF bug_count > 1 %] 
-        are [% bug_count %] [%+ terms.bugs %] 
-      [% ELSE %]
-        is 1 [% terms.bug %]
-      [% END %]
-      entered for this version!  When you delete this
-      version, <b><blink>ALL</blink></b> stored [% terms.bugs %] will be deleted,
-      too.
-      You could not even see the [% terms.bug %] history for this version anymore!
-      </td></tr></table>
+  outstanding for this version. You must move 
 
+  [% IF bug_count > 1 %]
+     those [% terms.bugs %] 
+  [% ELSE %]
+     that [% terms.bug %]
   [% END %]
+  to another version before you can delete this one.
 
-[% END %]
-
-[% IF bug_count == 0 || Param('allowbugdeletion') %]
+[% ELSE %]
 
   <p>Do you really want to delete this version?<p>
   
index f6945ccd34fe236cc1d9ac580deba213dc3980dd..2ec3ebe10862971b67767a415e04410be57ef908 100644 (file)
@@ -24,8 +24,6 @@
   #
   # product: string; the name of the product the version belonged to
   #
-  # deleted_bug_count: number; the number of bugs which were deleted
-  #                            (if bug deletion is allowed)
   #%]
   
 [% title = BLOCK %]Deleted Version '[% name FILTER html %]' of Product
   title = title
 %]
 
-<p>
-[% IF deleted_bug_count %]
-  Attachments, [% terms.bug %] activity and dependencies deleted for
-  [%+ deleted_bug_count %]
-  [% IF deleted_bug_count > 1 %] 
-    [%+ terms.bugs %]
-  [% ELSE %]
-    [%+ terms.bug %]
-  [% END %].
-
-  </p><p>
-  [% deleted_bug_count %]
-  [% IF deleted_bug_count > 1 %] 
-    [%+ terms.bugs %]
-  [% ELSE %]
-    [%+ terms.bug %]
-  [% END %]
-  deleted.
-
-[% ELSE %]
-  No [% terms.bugs %] were targetted at the version.
-[% END %]
-</p>
-
 <p>Version '[% name FILTER html %]' deleted.</p>
 
 <p>
index 19625ea72740064f6f2b1be307aabfd30afdfed3..7b7ba5134fc24485f10a9b448dddaf9f4c169589 100644 (file)
 ],
 
 'admin/milestones/deleted.html.tmpl' => [
-  'deleted_bug_count'
+  'bug_count'
 ],
 
 'admin/versions/confirm-delete.html.tmpl' => [
   'bug_count'
 ],
 
-'admin/versions/deleted.html.tmpl' => [
-  'deleted_bug_count'
-],
-
 'admin/settings/edit.html.tmpl' => [
   'name',
   'checkbox_name'
index 92bc52990397c673922c815924c68648c906d523..f5bb9703baa1438fcfa16a40f989fca1cca97ea3 100644 (file)
     [% title = "Blank Component Name Not Allowed" %]
     You must enter a name for this new component.
 
+  [% ELSIF error == "component_has_bugs" %]
+    [% title = BLOCK %]Component has [% terms.Bugs %][% END %]
+    There are [% nb FILTER html %] [%+ terms.bugs %] entered for this component!
+    You must reassign those [% terms.bugs %] to another component before you
+    can delete this one.
+
   [% ELSIF error == "component_must_have_a_name" %]
     [% title = "Blank Component Name Not Allowed" %]
     You cannot delete the component name for component '[% name FILTER html %]'.
     [% title = "Blank Milestone Name Not Allowed" %]
     You must enter a name for this milestone.
 
+  [% ELSIF error == "milestone_is_default" %]
+    [% title = "Default milestone not deletable" %]
+    Sorry, but [% name FILTER html %] is the default milestone for
+    product '[% product FILTER html %]', and so it can not be deleted.
+
   [% ELSIF error == "milestone_name_too_long" %]
     [% title = "Milestone Name Is Too Long" %]
     The name of a milestone is limited to 20 characters. 
     You are not permitted to edit [% terms.bugs %] in product 
     [% product FILTER html %].
 
+  [% ELSIF error == "product_has_bugs" %]
+    [% title = BLOCK %]Product has [% terms.Bugs %][% END %]
+    There are [% nb FILTER html %] [%+ terms.bugs %] entered for this product!
+    You must reassign those [% terms.bugs %] to another product before you
+    can delete this one.
+
   [% ELSIF error == "query_name_missing" %]
     [% title = "No Search Name Specified" %]
     You must enter a name for your search.
     [% title = "Blank Version Name Not Allowed" %]
     You must enter a name for this version.
 
+  [% ELSIF error == "version_has_bugs" %]
+    [% title = BLOCK %]Version has [% terms.Bugs %][% END %]
+    There are [% nb FILTER html %] [%+ terms.bugs %] associated with this
+    version! You must reassign those [% terms.bugs %] to another version
+    before you can delete this one.
+
   [% ELSIF error == "version_name_too_long" %]
     [% title = "Version Name Is Too Long" %]
     The name of a version is limited to 20 characters.