From: lpsolit%gmail.com <> Date: Mon, 24 Mar 2008 01:21:46 +0000 (+0000) Subject: Bug 424380: Bugzilla 3.0 lets you clear the resolution of resolved bugs - Patch by... X-Git-Tag: bugzilla-3.0.4~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7d8ea435c87ee1979e1ce2dc1bb2efbb42dfd02;p=thirdparty%2Fbugzilla.git Bug 424380: Bugzilla 3.0 lets you clear the resolution of resolved bugs - Patch by Frédéric Buclin r/a=mkanat --- diff --git a/process_bug.cgi b/process_bug.cgi index b2655919bb..207607bd3b 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -1098,19 +1098,22 @@ if (defined $cgi->param('qa_contact') } } +# By default, makes sure that all bugs are in a closed state. +# If $all_open is true, makes sure that all bugs are open. sub check_bugs_resolution { - my $idlist = shift; + my ($idlist, $all_open) = @_; my $dbh = Bugzilla->dbh; my $open_states = join(',', map {$dbh->quote($_)} BUG_STATE_OPEN); # The list has already been validated. $idlist = join(',', @$idlist); - my $is_open = + my $sql_cond = $all_open ? 'NOT' : ''; + my $has_unwanted_bugs = $dbh->selectrow_array("SELECT 1 FROM bugs WHERE bug_id IN ($idlist) - AND bug_status IN ($open_states)"); + AND bug_status $sql_cond IN ($open_states)"); - # If there is at least one open bug, then the test failed. - return !$is_open; + # If there are unwanted bugs, then the test fails. + return !$has_unwanted_bugs; } SWITCH: for ($cgi->param('knob')) { @@ -1133,6 +1136,9 @@ SWITCH: for ($cgi->param('knob')) { last SWITCH; }; /^clearresolution$/ && CheckonComment( "clearresolution" ) && do { + # All bugs must already be open. + check_bugs_resolution(\@idlist, 'all_open') + || ThrowUserError('resolution_deletion_not_allowed'); ChangeResolution($bug, ''); last SWITCH; }; diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 64fe816633..8009b95459 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -1311,6 +1311,10 @@ [% title = "Summary Needed" %] You must enter a summary for this [% terms.bug %]. + [% ELSIF error == "resolution_deletion_not_allowed" %] + [% title = "Resolution Change Not Allowed" %] + You cannot clear the resolution of open [% terms.bugs %]. + [% ELSIF error == "resolution_not_allowed" %] [% title = "Resolution Not Allowed" %] You cannot set a resolution for open [% terms.bugs %].