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

Bug 419243: get_new_status_and_resolution() no longer exists and bug moving…

Bug 419243: get_new_status_and_resolution() no longer exists and bug moving fails - Patch by Fré©ric Buclin <LpSolit@gmail.com> r/a=mkanat
parent f0dab615
...@@ -1349,11 +1349,6 @@ sub _check_resolution { ...@@ -1349,11 +1349,6 @@ sub _check_resolution {
# Make sure this is a valid resolution. # Make sure this is a valid resolution.
check_field('resolution', $resolution); check_field('resolution', $resolution);
# The moving code doesn't use set_resolution. This check prevents
# people from hacking the URL variables (or using some other interface)
# and setting a bug to MOVED without moving it.
ThrowCodeError('no_manual_moved') if $resolution eq 'MOVED';
# Don't allow open bugs to have resolutions. # Don't allow open bugs to have resolutions.
ThrowUserError('resolution_not_allowed') if $self->status->is_open; ThrowUserError('resolution_not_allowed') if $self->status->is_open;
...@@ -1867,12 +1862,16 @@ sub set_remaining_time { $_[0]->set('remaining_time', $_[1]); } ...@@ -1867,12 +1862,16 @@ sub set_remaining_time { $_[0]->set('remaining_time', $_[1]); }
sub _zero_remaining_time { $_[0]->{'remaining_time'} = 0; } sub _zero_remaining_time { $_[0]->{'remaining_time'} = 0; }
sub set_reporter_accessible { $_[0]->set('reporter_accessible', $_[1]); } sub set_reporter_accessible { $_[0]->set('reporter_accessible', $_[1]); }
sub set_resolution { sub set_resolution {
my ($self, $value, $dupe_of) = @_; my ($self, $value, $params) = @_;
my $old_res = $self->resolution; my $old_res = $self->resolution;
$self->set('resolution', $value); $self->set('resolution', $value);
my $new_res = $self->resolution; my $new_res = $self->resolution;
# MOVED has a special meaning and can only be used when
# really moving bugs to another installation.
ThrowCodeError('no_manual_moved') if ($new_res eq 'MOVED' && !$params->{moving});
if ($new_res ne $old_res) { if ($new_res ne $old_res) {
# Clear the dup_id if we're leaving the dup resolution. # Clear the dup_id if we're leaving the dup resolution.
if ($old_res eq 'DUPLICATE') { if ($old_res eq 'DUPLICATE') {
...@@ -1889,8 +1888,8 @@ sub set_resolution { ...@@ -1889,8 +1888,8 @@ sub set_resolution {
# of another, theoretically. Note that this code block will also run # of another, theoretically. Note that this code block will also run
# when going between different closed states. # when going between different closed states.
if ($self->resolution eq 'DUPLICATE') { if ($self->resolution eq 'DUPLICATE') {
if ($dupe_of) { if ($params->{dupe_of}) {
$self->set_dup_id($dupe_of); $self->set_dup_id($params->{dupe_of});
} }
elsif (!$self->dup_id) { elsif (!$self->dup_id) {
ThrowUserError('dupe_id_required'); ThrowUserError('dupe_id_required');
...@@ -1912,7 +1911,7 @@ sub clear_resolution { ...@@ -1912,7 +1911,7 @@ sub clear_resolution {
} }
sub set_severity { $_[0]->set('bug_severity', $_[1]); } sub set_severity { $_[0]->set('bug_severity', $_[1]); }
sub set_status { sub set_status {
my ($self, $status, $resolution, $dupe_of) = @_; my ($self, $status, $params) = @_;
my $old_status = $self->status; my $old_status = $self->status;
$self->set('bug_status', $status); $self->set('bug_status', $status);
delete $self->{'status'}; delete $self->{'status'};
...@@ -1926,8 +1925,9 @@ sub set_status { ...@@ -1926,8 +1925,9 @@ sub set_status {
else { else {
# We do this here so that we can make sure closed statuses have # We do this here so that we can make sure closed statuses have
# resolutions. # resolutions.
$self->set_resolution($resolution || $self->resolution, $dupe_of); my $resolution = delete $params->{resolution} || $self->resolution;
$self->set_resolution($resolution, $params);
# Changing between closed statuses zeros the remaining time. # Changing between closed statuses zeros the remaining time.
if ($new_status->id != $old_status->id && $self->remaining_time != 0) { if ($new_status->id != $old_status->id && $self->remaining_time != 0) {
$self->_zero_remaining_time(); $self->_zero_remaining_time();
...@@ -2647,14 +2647,14 @@ sub process_knob { ...@@ -2647,14 +2647,14 @@ sub process_knob {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
return if $action eq 'none'; return if $action eq 'none';
my $dupe_move_status = Bugzilla->params->{'duplicate_or_move_bug_status'};
if ($action eq 'duplicate') { if ($action eq 'duplicate') {
$self->set_status(Bugzilla->params->{'duplicate_or_move_bug_status'}, $self->set_status($dupe_move_status,
'DUPLICATE', $dupe_of); {resolution => 'DUPLICATE', dupe_of => $dupe_of});
} }
elsif ($action eq 'move') { elsif ($action eq 'move') {
$self->set_status(Bugzilla->params->{'duplicate_or_move_bug_status'}, $self->set_status($dupe_move_status, {resolution => 'MOVED'});
'MOVED');
} }
elsif ($action eq 'change_resolution') { elsif ($action eq 'change_resolution') {
$self->set_resolution($to_resolution); $self->set_resolution($to_resolution);
...@@ -2663,7 +2663,7 @@ sub process_knob { ...@@ -2663,7 +2663,7 @@ sub process_knob {
$self->clear_resolution(); $self->clear_resolution();
} }
else { else {
$self->set_status($action, $to_resolution); $self->set_status($action, {resolution => $to_resolution});
} }
} }
......
...@@ -428,22 +428,15 @@ if ($move_action eq Bugzilla->params->{'move-button-text'}) { ...@@ -428,22 +428,15 @@ if ($move_action eq Bugzilla->params->{'move-button-text'}) {
# First update all moved bugs. # First update all moved bugs.
foreach my $bug (@bug_objects) { foreach my $bug (@bug_objects) {
$bug->add_comment(scalar $cgi->param('comment'), $bug->add_comment('', { type => CMT_MOVED_TO, extra_data => $user->login });
{ type => CMT_MOVED_TO, extra_data => $user->login });
} }
# Don't export the new status and resolution. We want the current ones. # Don't export the new status and resolution. We want the current ones.
local $Storable::forgive_me = 1; local $Storable::forgive_me = 1;
my $bugs = dclone(\@bug_objects); my $bugs = dclone(\@bug_objects);
my $new_status = Bugzilla->params->{'duplicate_or_move_bug_status'};
foreach my $bug (@bug_objects) { foreach my $bug (@bug_objects) {
my ($status, $resolution) = $bug->get_new_status_and_resolution('move'); $bug->set_status($new_status, {resolution => 'MOVED', moving => 1});
$bug->set_status($status);
# 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; $_->update() foreach @bug_objects;
$dbh->bz_commit_transaction(); $dbh->bz_commit_transaction();
......
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