From 620caf6860a86bf0f54918e8514c14d7cec5f2cc Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 18 Jan 2008 02:41:44 +0000 Subject: Bug 402791: Move status and resolution updating from process_bug.cgi into Bugzilla::Bug Patch By Max Kanat-Alexander r=LpSolit, a=LpSolit --- process_bug.cgi | 257 +++++++++++++++----------------------------------------- 1 file changed, 69 insertions(+), 188 deletions(-) (limited to 'process_bug.cgi') diff --git a/process_bug.cgi b/process_bug.cgi index dcea4ffba..71be09168 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -75,7 +75,6 @@ $vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); my @editable_bug_fields = editable_bug_fields(); -my $requiremilestone = 0; local our $PrivilegesRequired = 0; ###################################################################### @@ -268,48 +267,9 @@ if (should_set('product')) { } } -# Confirm that the reporter of the current bug can access the bug we are duping to. -sub DuplicateUserConfirm { - my ($dupe, $original) = @_; - my $cgi = Bugzilla->cgi; - my $dbh = Bugzilla->dbh; - my $template = Bugzilla->template; - - # if we've already been through here, then exit - if (defined $cgi->param('confirm_add_duplicate')) { - return; - } - - if ($dupe->reporter->can_see_bug($original)) { - $cgi->param('confirm_add_duplicate', '1'); - return; - } - elsif (Bugzilla->usage_mode == USAGE_MODE_EMAIL) { - # The email interface defaults to the safe alternative, which is - # not CC'ing the user. - $cgi->param('confirm_add_duplicate', 0); - return; - } - - $vars->{'cclist_accessible'} = $dbh->selectrow_array( - q{SELECT cclist_accessible FROM bugs WHERE bug_id = ?}, - undef, $original); - - # Once in this part of the subroutine, the user has not been auto-validated - # and the duper has not chosen whether or not to add to CC list, so let's - # ask the duper what he/she wants to do. - - $vars->{'original_bug_id'} = $original; - $vars->{'duplicate_bug_id'} = $dupe->bug_id; - - # Confirm whether or not to add the reporter to the cc: list - # of the original bug (the one this bug is being duped against). - print Bugzilla->cgi->header(); - $template->process("bug/process/confirm-duplicate.html.tmpl", $vars) - || ThrowTemplateError($template->error()); - exit; -} - +# Component, target_milestone, and version are in here just in case +# the 'product' field wasn't defined in the CGI. It doesn't hurt to set +# them twice. my @set_fields = qw(op_sys rep_platform priority bug_severity component target_milestone version bug_file_loc status_whiteboard short_desc @@ -324,9 +284,13 @@ my %methods = ( bug_file_loc => 'set_url', ); foreach my $b (@bug_objects) { - # Component, target_milestone, and version are in here just in case - # the 'product' field wasn't defined in the CGI. It doesn't hurt to set - # them twice. + if (should_set('comment') || $cgi->param('work_time')) { + # Add a comment as needed to each bug. This is done early because + # there are lots of things that want to check if we added a comment. + $b->add_comment(scalar($cgi->param('comment')), + { isprivate => scalar $cgi->param('commentprivacy'), + work_time => scalar $cgi->param('work_time') }); + } foreach my $field_name (@set_fields) { if (should_set($field_name)) { my $method = $methods{$field_name}; @@ -480,7 +444,13 @@ if ($action eq Bugzilla->params->{'move-button-text'}) { foreach my $bug (@bug_objects) { my ($status, $resolution) = $bug->get_new_status_and_resolution('move'); $bug->set_status($status); - $bug->set_resolution($resolution); + # We don't use set_resolution here because the MOVED resolution is + # special and is normally rejected by set_resolution. + $bug->{resolution} = $resolution; + # That means that we need to clear dups manually. Eventually this + # bug-moving code will all be inside Bugzilla::Bug, so it's OK + # to call an internal function here. + $bug->_clear_dup_id; } $_->update() foreach @bug_objects; $dbh->bz_unlock_tables(); @@ -527,56 +497,34 @@ if ($action eq Bugzilla->params->{'move-button-text'}) { } -if (($cgi->param('set_default_assignee') || $cgi->param('set_default_qa_contact')) - && Bugzilla->params->{'commentonreassignbycomponent'} && !comment_exists()) -{ - ThrowUserError('comment_required'); +# You cannot mark bugs as duplicates when changing several bugs at once +# (because currently there is no way to check for duplicate loops in that +# situation). +if (!$cgi->param('id') && $cgi->param('dup_id')) { + ThrowUserError('dupe_not_allowed'); } -my $duplicate; # It will store the ID of the bug we are pointing to, if any. - -# Make sure the bug status transition is legal for all bugs. -my $knob = scalar $cgi->param('knob'); -# Special actions (duplicate, change_resolution and clearresolution) are outside -# the workflow. -if (!grep { $knob eq $_ } SPECIAL_STATUS_WORKFLOW_ACTIONS) { - # Make sure the bug status exists and is active. - check_field('bug_status', $knob); - my $bug_status = new Bugzilla::Status({name => $knob}); - $_->check_status_transition($bug_status) foreach @bug_objects; - - # Fill the resolution field with the correct value (e.g. in case the - # workflow allows several open -> closed transitions). - if ($bug_status->is_open) { - $cgi->delete('resolution'); - } - else { - $cgi->param('resolution', $cgi->param('resolution_knob_' . $bug_status->id)); +# Set the status, resolution, and dupe_of (if needed). This has to be done +# down here, because the validity of status changes depends on other fields, +# such as Target Milestone. +foreach my $b (@bug_objects) { + if (should_set('knob')) { + # First, get the correct resolution