From 73553366455cb23a6df1847d67bde74386c87742 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Mon, 8 Oct 2007 05:06:19 +0000 Subject: Bug 398739: "Taking a bug" while adding a new attachment locks the bug status forever if the ASSIGNED bug status has been renamed or deleted - Patch by Frédéric Buclin r=mkanat a=LpSolit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attachment.cgi | 57 ++++++++++++++++++++------------------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) (limited to 'attachment.cgi') diff --git a/attachment.cgi b/attachment.cgi index 13d225bdd..d9521b591 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -359,45 +359,28 @@ sub insert { # Assign the bug to the user, if they are allowed to take it my $owner = ""; - if ($cgi->param('takebug') && $user->in_group('editbugs', $bug->product_id)) { - - my @fields = ("assigned_to", "bug_status", "resolution", "everconfirmed", - "login_name"); - - # Get the old values, for the bugs_activity table - my @oldvalues = $dbh->selectrow_array( - "SELECT " . join(", ", @fields) . " " . - "FROM bugs " . - "INNER JOIN profiles " . - "ON profiles.userid = bugs.assigned_to " . - "WHERE bugs.bug_id = ?", undef, $bugid); - - my @newvalues = ($user->id, "ASSIGNED", "", 1, $user->login); - + # When taking a bug, we have to follow the workflow. + my $bug_status = $cgi->param('bug_status') || ''; + ($bug_status) = grep {$_->name eq $bug_status} @{$bug->status->can_change_to}; + + if ($bug_status && $bug_status->is_open + && ($bug_status->name ne 'UNCONFIRMED' || $bug->product_obj->votes_to_confirm)) + { + $bug->set_status($bug_status->name); + $bug->clear_resolution(); + $bug->update($timestamp); + } # Make sure the person we are taking the bug from gets mail. - $owner = $oldvalues[4]; - - # Update the bug record. Note that this doesn't involve login_name. - $dbh->do('UPDATE bugs SET delta_ts = ?, ' . - join(', ', map("$fields[$_] = ?", (0..3))) . ' WHERE bug_id = ?', - undef, ($timestamp, map($newvalues[$_], (0..3)) , $bugid)); - - # If the bug was a dupe, we have to remove its entry from the - # 'duplicates' table. - $dbh->do('DELETE FROM duplicates WHERE dupe = ?', undef, $bugid); - - # We store email addresses in the bugs_activity table rather than IDs. - $oldvalues[0] = $oldvalues[4]; - $newvalues[0] = $newvalues[4]; - - for (my $i = 0; $i < 4; $i++) { - if ($oldvalues[$i] ne $newvalues[$i]) { - LogActivityEntry($bugid, $fields[$i], $oldvalues[$i], - $newvalues[$i], $user->id, $timestamp); - } - } - } + $owner = $bug->assigned_to->login; + + # Ideally, the code below should be replaced by $bug->set_assignee(). + $dbh->do('UPDATE bugs SET assigned_to = ?, delta_ts = ? WHERE bug_id = ?', + undef, ($user->id, $timestamp, $bugid)); + + LogActivityEntry($bugid, 'assigned_to', $owner, $user->login, $user->id, $timestamp); + + } # Define the variables and functions that will be passed to the UI template. $vars->{'mailrecipients'} = { 'changer' => $user->login, -- cgit v1.2.3-24-g4f1b