]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1047539 - Bugmails including "See Also" bug links do not include a "Referenced...
authorKohei Yoshino <kohei.yoshino@gmail.com>
Tue, 19 Feb 2019 15:17:34 +0000 (10:17 -0500)
committerGitHub <noreply@github.com>
Tue, 19 Feb 2019 15:17:34 +0000 (10:17 -0500)
Bugzilla/BugMail.pm

index d5c1c4c95bce7802c0c0673f2d3612de488c2aed..47edac7511439dd39d5892197f25da591db785c0 100644 (file)
@@ -137,6 +137,7 @@ sub Send {
   if (!$start) {
     push @referenced_bugs, @{$bug->dependson};
     push @referenced_bugs, @{$bug->blocked};
+    push @referenced_bugs, _parse_see_also(map { $_->name } @{$bug->see_also});
   }
 
   # If no changes have been made, there is no need to process further.
@@ -599,6 +600,11 @@ sub _get_diffs {
       push @$referenced_bugs, grep {/^\d+$/} split(/[\s,]+/, $diff->{old});
       push @$referenced_bugs, grep {/^\d+$/} split(/[\s,]+/, $diff->{new});
     }
+    elsif ($diff->{field_name} eq 'see_also') {
+      foreach my $field ('new', 'old') {
+        push @$referenced_bugs, _parse_see_also(split(/[\s,]+/, $diff->{$field}));
+      }
+    }
   }
 
   return ($diffs, $referenced_bugs);
@@ -665,4 +671,12 @@ sub _get_new_bugmail_fields {
   return @diffs;
 }
 
+sub _parse_see_also {
+  my (@links) = @_;
+  my $urlbase = Bugzilla->localconfig->{urlbase};
+  my $bug_link_re = qr/^\Q$urlbase\Eshow_bug\.cgi\?id=(\d+)$/;
+
+  return grep { /^\d+$/ } map { /$bug_link_re/ ? int($1) : () } @links;
+}
+
 1;