From: justdave%syndicomm.com <> Date: Thu, 18 Mar 2004 13:55:41 +0000 (+0000) Subject: Bug 24496: Adds a parameter "noresolveonopenblockers" which when enabled, prevents... X-Git-Tag: bugzilla-2.18rc1~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39a329b9ac46424a4552e8c68e44467173a8238c;p=thirdparty%2Fbugzilla.git Bug 24496: Adds a parameter "noresolveonopenblockers" which when enabled, prevents bugs from being closed if there are any bugs blocking it which are still open. Patch by Andreas Höfler r= justdave, a= myk --- diff --git a/defparams.pl b/defparams.pl index 1d492de20b..d25f119103 100644 --- a/defparams.pl +++ b/defparams.pl @@ -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; diff --git a/globals.pl b/globals.pl index 399482caa9..019d6d9722 100644 --- a/globals.pl +++ b/globals.pl @@ -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 = ""; diff --git a/process_bug.cgi b/process_bug.cgi index 774883a9c5..4df90efd2f 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -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'); diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 1577619ee3..3bbca0cec5 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -666,6 +666,32 @@ Sorry - sidebar.cgi currently only supports Mozilla based web browsers. Upgrade today. :-) + [% ELSIF error == "still_unresolved_bugs" %] + [% IF dependency_count == 1 %] + [% terms.Bug %]# [% dependencies.0.bug_id %] + has still [% dependencies.0.dependencies FILTER html %] unresolved + [% IF dependencies.0.dependencies == 1 %] + dependency + [% ELSE %] + dependencies + [% END %]. Show + Dependency Tree. + [% ELSE %] + There are [% dependency_count %] open [% terms.bugs %] which + have unresolved dependencies. +
+ [% FOREACH bug = dependencies %] + [% terms.Bug %]# [% bug.bug_id %] + has [% bug.dependencies FILTER html %] open + [% IF bug.dependencies == 1 %] + dependency. + [% ELSE %] + dependencies. + [% END %] + (Dependency Tree)
+ [% 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