]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 398739: "Taking a bug" while adding a new attachment locks the bug status forever...
authorlpsolit%gmail.com <>
Mon, 8 Oct 2007 05:06:19 +0000 (05:06 +0000)
committerlpsolit%gmail.com <>
Mon, 8 Oct 2007 05:06:19 +0000 (05:06 +0000)
Bugzilla/Bug.pm
attachment.cgi
template/en/default/attachment/create.html.tmpl

index 1e1dee712a611da3e7ec094d54340cd59d9d3c56..e1b4a6e55e6f1fea2c326d4a40b4246637550a8a 100755 (executable)
@@ -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) = @_;
index 13d225bddcfb57a6d9a7328fe1448be718660a34..d9521b5914fb688265b23eb8b83151f5b70fcdcb 100755 (executable)
@@ -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,
index 10a6abec2fe12dee8657cd29e4ff3bfa9e390d5b..781674a960dc0669666ff22e51e1da5f8bdc4e4f 100644 (file)
               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 %]