diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index f4f1069d26..36c4e53572 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -4636,14 +4636,14 @@ sub GetBugActivity { foreach my $value (split /, /, $removed) { if (substr($value, 0, length $url_base) eq $url_base) { my ($bug_id) = $value =~ /id=(\d+)$/; - next if !Bugzilla->user->can_see_bug($bug_id); + next if !$bug_id || !Bugzilla->user->can_see_bug($bug_id); } push @filtered_removed, $value; } foreach my $value (split /, /, $added) { if (substr($value, 0, length $url_base) eq $url_base) { my ($bug_id) = $value =~ /id=(\d+)$/; - next if !Bugzilla->user->can_see_bug($bug_id); + next if !$bug_id || !Bugzilla->user->can_see_bug($bug_id); } push @filtered_added, $value; } diff --git a/Bugzilla/BugUrl/Bugzilla/Local.pm b/Bugzilla/BugUrl/Bugzilla/Local.pm index 8ae5d3ff26..c358027389 100644 --- a/Bugzilla/BugUrl/Bugzilla/Local.pm +++ b/Bugzilla/BugUrl/Bugzilla/Local.pm @@ -13,6 +13,7 @@ use warnings; use base qw(Bugzilla::BugUrl::Bugzilla); +use Bugzilla::Bug qw(bug_alias_to_id); use Bugzilla::Error; use Bugzilla::Util; @@ -73,7 +74,19 @@ sub _check_value { $uri = $class->SUPER::_check_value($uri); } - my $ref_bug_id = $uri->query_param('id'); + # If bug ID is an alias, we want to store the value in the DB + # as the actual ID instead of the alias for visibility checking + # and other parts of the code. + my $ref_bug_id = $uri->query_param('id'); + if ($ref_bug_id !~ /^\d+$/) { + my $orig_ref_bug_id = $ref_bug_id; + $ref_bug_id = bug_alias_to_id($ref_bug_id); + $ref_bug_id + || ThrowUserError('improper_bug_id_field_value', + {bug_id => $orig_ref_bug_id}); + $uri->query_param('id', $ref_bug_id); + } + my $ref_bug = Bugzilla::Bug->check($ref_bug_id); my $self_bug_id = $params->{bug_id}; $params->{ref_bug} = $ref_bug;