]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 24496: Adds a parameter "noresolveonopenblockers" which when enabled, prevents...
authorjustdave%syndicomm.com <>
Thu, 18 Mar 2004 13:55:41 +0000 (13:55 +0000)
committerjustdave%syndicomm.com <>
Thu, 18 Mar 2004 13:55:41 +0000 (13:55 +0000)
Patch by Andreas Höfler <andreas.hoefler@bearingpoint.com>
r= justdave, a= myk

defparams.pl
globals.pl
process_bug.cgi
template/en/default/global/user-error.html.tmpl

index 1d492de20b5806ec629877da210bd97f7d9e9396..d25f119103e72e40590aa4a8a3573edc4d2edf98 100644 (file)
@@ -1169,7 +1169,14 @@ Reason: %reason%
    type    => 't',
    default => '',
   },
-);
 
+  {
+   name    => 'noresolveonopenblockers',
+   desc    => 'Don\'t allow bugs to be resolved as fixed if they have unresolved dependencies.',
+   type    => 'b',
+   default => 0,
+  },
+  
+);
 1;
 
index 399482caa95bd0ecd5f36ca4ce60cb970a92f6e5..019d6d97222874e2bf5c19966e83b585841fcd3d 100644 (file)
@@ -1069,6 +1069,38 @@ sub GetBugLink {
     }
 }
 
+# CountOpenDependencies counts the number of open dependent bugs for a
+# list of bugs and returns a list of bug_id's and their dependency count
+# It takes one parameter:
+#  - A list of bug numbers whose dependencies are to be checked
+
+sub CountOpenDependencies {
+    my (@bug_list) = @_;
+    my @dependencies;
+    
+    # Make sure any unfetched data from a currently running query
+    # is saved off rather than overwritten
+    PushGlobalSQLState();
+   
+    SendSQL("SELECT blocked, count(bug_status) " .
+            "FROM bugs, dependencies " .
+            "WHERE blocked IN (" . (join "," , @bug_list) . ") " .
+            "AND bug_id = dependson " .
+            "AND bug_status IN ('" . (join "','", OpenStates())  . "') " .
+            "GROUP BY blocked ");
+   
+    while (MoreSQLData()) {
+        my ($bug_id, $dependencies) = FetchSQLData();
+        push(@dependencies, { bug_id       => $bug_id, 
+                              dependencies => $dependencies });
+    }
+
+    # All done with this sidetrip
+    PopGlobalSQLState();
+
+    return @dependencies;
+}
+
 sub GetLongDescriptionAsText {
     my ($id, $start, $end) = (@_);
     my $result = "";
index 774883a9c5b2c252cef60fdb5fdf3943b1c62b67..4df90efd2fcff695659b11a0e5add52ba764f47f 100755 (executable)
@@ -890,6 +890,17 @@ SWITCH: for ($::FORM{'knob'}) {
                 ThrowUserError("resolving_remaining_time");
             }
         }
+        
+        # don't resolve as fixed while still unresolved blocking bugs
+        if (Param("noresolveonopenblockers") && ($::FORM{'resolution'} eq 'FIXED')) {
+           my @dependencies = CountOpenDependencies(@idlist);
+           if (scalar @dependencies > 0) {
+               ThrowUserError("still_unresolved_bugs", 
+                               { dependencies     => \@dependencies,
+                                 dependency_count => scalar @dependencies });
+            }          
+        }
+
         # Check here, because its the only place we require the resolution
         CheckFormField(\%::FORM, 'resolution', \@::settable_resolution);
         ChangeStatus('RESOLVED');
index 1577619ee3a146b9db786f6330b66c7757ae1641..3bbca0cec5ceb42604a3d0b44f441c515970ca2e 100644 (file)
     Sorry - sidebar.cgi currently only supports Mozilla based web browsers.
     <a href="http://www.mozilla.org">Upgrade today</a>. :-)
 
+  [% ELSIF error == "still_unresolved_bugs" %]
+    [% IF dependency_count == 1 %]
+      [% terms.Bug %]# <a href="show_bug.cgi?id=[% dependencies.0.bug_id %]">[% dependencies.0.bug_id %]</a>
+      has still [% dependencies.0.dependencies FILTER html %] unresolved
+      [% IF dependencies.0.dependencies == 1 %]
+        dependency
+      [% ELSE %]
+        dependencies
+      [% END %]. Show
+      <a href="showdependencytree.cgi?id=[% dependencies.0.bug_id %]">Dependency Tree</a>.
+    [% ELSE %]
+      There are [% dependency_count %] open [% terms.bugs %] which
+      have unresolved dependencies.
+      <br>
+      [% FOREACH bug = dependencies %]
+        [% terms.Bug %]# <a href="show_bug.cgi?id=[% bug.bug_id %]">[% bug.bug_id %]</a>
+        has [% bug.dependencies FILTER html %] open
+        [% IF bug.dependencies == 1 %]
+          dependency.
+        [% ELSE %]
+          dependencies.
+        [% END %]
+        (<a href="showdependencytree.cgi?id=[% bug.bug_id %]">Dependency Tree</a>)<br>
+      [% END %]
+    [% END %]
+
   [% ELSIF error == "too_many_votes_for_bug" %]
     [% title = "Illegal Vote" %]
     You may only use at most [% max FILTER html %] votes for a single