diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index c77df8f06..64a539b03 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -3289,8 +3289,18 @@ sub _in_search_results } else { - $self->{term}->{where} = "$self->{fieldsql} = $t.bug_id"; - $self->{term}->{notnull_field} = "$t.bug_id"; + my $f = Bugzilla->get_field($self->{field}); + if ($f && ($f->type == FIELD_TYPE_BUG_ID || $f->type == FIELD_TYPE_BUG_ID_REV) || + $self->{field} eq 'blocked' || $self->{field} eq 'dependson' || $self->{field} eq 'dup_id') + { + $self->{term}->{where} = "$self->{fieldsql} = $t.bug_id"; + $self->{term}->{notnull_field} = "$t.bug_id"; + $self->{term}->{supp} = [ @{$self->{supptables}} ]; + } + else + { + ThrowUserError('in_search_needs_bugid_field', { field => $self->{field} }); + } } } diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 595203611..fd36c7aa2 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -532,6 +532,11 @@ Can't use [% field FILTER html %] as a field name. [% END %] +[% BLOCK error_in_search_needs_bugid_field %] + Subquery search operator ("In Search Results") can only be applied to fields of type "Bug ID". + "[% field | html %]" is not a Bug ID field. +[% END %] + [% BLOCK error_useless_customfield_type %] [% title = "Can't create field of a useless type" %] It is impossible to create "[% lc_messages.field_types.$type %]" fields,