Commit 73553366 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 398739: "Taking a bug" while adding a new attachment locks the bug status…

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é©ric Buclin <LpSolit@gmail.com> r=mkanat a=LpSolit
parent bd370f37
......@@ -1466,6 +1466,7 @@ sub set_remaining_time { $_[0]->set('remaining_time', $_[1]); }
sub _zero_remaining_time { $_[0]->{'remaining_time'} = 0; }
sub set_reporter_accessible { $_[0]->set('reporter_accessible', $_[1]); }
sub set_resolution { $_[0]->set('resolution', $_[1]); }
sub clear_resolution { $_[0]->{'resolution'} = '' }
sub set_severity { $_[0]->set('bug_severity', $_[1]); }
sub set_status {
my ($self, $status) = @_;
......
......@@ -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,
......
......@@ -73,6 +73,21 @@
check the box below.</em><br>
<input type="checkbox" id="takebug" name="takebug" value="1">
<label for="takebug">take [% terms.bug %]</label>
[% bug_statuses = [] %]
[% FOREACH bug_status = bug.status.can_change_to %]
[% NEXT IF bug_status.name == "UNCONFIRMED" && !bug.product_obj.votes_to_confirm %]
[% bug_statuses.push(bug_status) IF bug_status.is_open %]
[% END %]
[% IF bug_statuses.size %]
<label for="takebug">and set the [% terms.bug %] status to</label>
<select id="bug_status" name="bug_status">
<option label="[% bug.status.name FILTER html %]">[% bug.status.name FILTER html %] (current)</option>
[% FOREACH bug_status = bug_statuses %]
[% NEXT IF bug_status.id == bug.status.id %]
<option label="[% bug_status.name FILTER html %]">[% bug_status.name FILTER html %]</option>
[% END %]
</select>
[% END %]
</td>
</tr>
[% END %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment