]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1599620 - Don't auto-assign if there are no reviewers specified.
authordklawren <dklawren@users.noreply.github.com>
Mon, 9 Dec 2019 14:59:17 +0000 (09:59 -0500)
committerGitHub <noreply@github.com>
Mon, 9 Dec 2019 14:59:17 +0000 (09:59 -0500)
extensions/PhabBugz/lib/Util.pm

index 11f9a314f30acc9f7229771355987e028e2f7d02..21e1091061ad0e7ac03721d42310fa64c139a11d 100644 (file)
@@ -54,44 +54,46 @@ sub create_revision_attachment {
   # BMO does not contain actual diff content.
   my @review_attachments
     = grep { is_attachment_phab_revision($_) } @{$bug->attachments};
-  my $review_attachment
+  my $attachment
     = first { trim($_->data) eq $revision_uri } @review_attachments;
-  return $review_attachment if defined $review_attachment;
 
-  # No attachment is present, so we can now create new one
+  if (!defined $attachment) {
+    # No attachment is present, so we can now create new one
 
-  if (!$timestamp) {
-    ($timestamp) = Bugzilla->dbh->selectrow_array("SELECT NOW()");
-  }
-
-  # If submitter, then switch to that user when creating attachment
-  local $submitter->{groups} = [Bugzilla::Group->get_all]; # We need to always be able to add attachment
-  my $restore_prev_user = Bugzilla->set_user($submitter, scope_guard => 1);
-
-  my $attachment = Bugzilla::Attachment->create({
-    bug         => $bug,
-    creation_ts => $timestamp,
-    data        => $revision_uri,
-    description => $revision->title,
-    filename    => 'phabricator-D' . $revision->id . '-url.txt',
-    ispatch     => 0,
-    isprivate   => 0,
-    mimetype    => PHAB_CONTENT_TYPE,
-  });
-
-  # Insert a comment about the new attachment into the database.
-  $bug->add_comment(
-    $revision->summary,
-    {
-      type        => CMT_ATTACHMENT_CREATED,
-      extra_data  => $attachment->id,
-      is_markdown => (Bugzilla->params->{use_markdown} ? 1 : 0)
+    if (!$timestamp) {
+      ($timestamp) = Bugzilla->dbh->selectrow_array("SELECT NOW()");
     }
-  );
-  delete $bug->{attachments};
 
-  # Assign the bug to the submitter if it isn't already owned.
-  unless (is_bug_assigned($bug)) {
+    # If submitter, then switch to that user when creating attachment
+    local $submitter->{groups} = [Bugzilla::Group->get_all]; # We need to always be able to add attachment
+    my $restore_prev_user = Bugzilla->set_user($submitter, scope_guard => 1);
+
+    $attachment = Bugzilla::Attachment->create({
+      bug         => $bug,
+      creation_ts => $timestamp,
+      data        => $revision_uri,
+      description => $revision->title,
+      filename    => 'phabricator-D' . $revision->id . '-url.txt',
+      ispatch     => 0,
+      isprivate   => 0,
+      mimetype    => PHAB_CONTENT_TYPE,
+    });
+
+    # Insert a comment about the new attachment into the database.
+    $bug->add_comment(
+      $revision->summary,
+      {
+        type        => CMT_ATTACHMENT_CREATED,
+        extra_data  => $attachment->id,
+        is_markdown => (Bugzilla->params->{use_markdown} ? 1 : 0)
+      }
+    );
+    delete $bug->{attachments};
+  }
+
+  # Assign the bug to the submitter if it isn't already owned and
+  # the revision has reviewers assigned to it.
+  if (!is_bug_assigned($bug) && @{$revision->reviews}) {
     $bug->set_assigned_to($submitter);
     $bug->set_bug_status('ASSIGNED') if $bug->status->name eq 'NEW';
   }