]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 419243: get_new_status_and_resolution() no longer exists and bug moving fails...
authorlpsolit%gmail.com <>
Tue, 26 Feb 2008 06:05:21 +0000 (06:05 +0000)
committerlpsolit%gmail.com <>
Tue, 26 Feb 2008 06:05:21 +0000 (06:05 +0000)
Bugzilla/Bug.pm
process_bug.cgi

index a5d25885e944d27edd19d60e054878ae6028f3f1..96f185c1fc8008659b8f6f454f119d0557a583d6 100755 (executable)
@@ -1349,11 +1349,6 @@ sub _check_resolution {
     # Make sure this is a valid 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.
     ThrowUserError('resolution_not_allowed') if $self->status->is_open;
     
@@ -1867,12 +1862,16 @@ 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 {
-    my ($self, $value, $dupe_of) = @_;
+    my ($self, $value, $params) = @_;
     
     my $old_res = $self->resolution;
     $self->set('resolution', $value);
     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) {
         # Clear the dup_id if we're leaving the dup resolution.
         if ($old_res eq 'DUPLICATE') {
@@ -1889,8 +1888,8 @@ sub set_resolution {
     # of another, theoretically. Note that this code block will also run
     # when going between different closed states.
     if ($self->resolution eq 'DUPLICATE') {
-        if ($dupe_of) {
-            $self->set_dup_id($dupe_of);
+        if ($params->{dupe_of}) {
+            $self->set_dup_id($params->{dupe_of});
         }
         elsif (!$self->dup_id) {
             ThrowUserError('dupe_id_required');
@@ -1912,7 +1911,7 @@ sub clear_resolution {
 }
 sub set_severity       { $_[0]->set('bug_severity',  $_[1]); }
 sub set_status {
-    my ($self, $status, $resolution, $dupe_of) = @_;
+    my ($self, $status, $params) = @_;
     my $old_status = $self->status;
     $self->set('bug_status', $status);
     delete $self->{'status'};
@@ -1926,8 +1925,9 @@ sub set_status {
     else {
         # We do this here so that we can make sure closed statuses have
         # 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.
         if ($new_status->id != $old_status->id && $self->remaining_time != 0) {
             $self->_zero_remaining_time();
@@ -2647,14 +2647,14 @@ sub process_knob {
     my $dbh = Bugzilla->dbh;
 
     return if $action eq 'none';
-    
+
+    my $dupe_move_status = Bugzilla->params->{'duplicate_or_move_bug_status'};
     if ($action eq 'duplicate') {
-        $self->set_status(Bugzilla->params->{'duplicate_or_move_bug_status'},
-                          'DUPLICATE', $dupe_of);
+        $self->set_status($dupe_move_status,
+                          {resolution => 'DUPLICATE', dupe_of => $dupe_of});
     }
     elsif ($action eq 'move') {
-        $self->set_status(Bugzilla->params->{'duplicate_or_move_bug_status'},
-                          'MOVED');
+        $self->set_status($dupe_move_status, {resolution => 'MOVED'});
     }
     elsif ($action eq 'change_resolution') {
         $self->set_resolution($to_resolution);
@@ -2663,7 +2663,7 @@ sub process_knob {
         $self->clear_resolution();
     }
     else {
-        $self->set_status($action, $to_resolution);
+        $self->set_status($action, {resolution => $to_resolution});
     }
 }
 
index 93b2ec1ff3e83f5314c1219eb27705d84dc9b0a4..277cbb0fdbf232d85ef29cc5b8ee89768a8a7d29 100755 (executable)
@@ -428,22 +428,15 @@ if ($move_action eq Bugzilla->params->{'move-button-text'}) {
 
     # First update all moved bugs.
     foreach my $bug (@bug_objects) {
-        $bug->add_comment(scalar $cgi->param('comment'),
-                          { type => CMT_MOVED_TO, extra_data => $user->login });
+        $bug->add_comment('', { type => CMT_MOVED_TO, extra_data => $user->login });
     }
     # Don't export the new status and resolution. We want the current ones.
     local $Storable::forgive_me = 1;
     my $bugs = dclone(\@bug_objects);
+
+    my $new_status = Bugzilla->params->{'duplicate_or_move_bug_status'};
     foreach my $bug (@bug_objects) {
-        my ($status, $resolution) = $bug->get_new_status_and_resolution('move');
-        $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;
+        $bug->set_status($new_status, {resolution => 'MOVED', moving => 1});
     }
     $_->update() foreach @bug_objects;
     $dbh->bz_commit_transaction();