=back
+=head2 quicksearch_run
+
+This hook allows you to alter the QuickSearch params, so you can, for example,
+include specific bug status or exclude specific products in search results
+by default.
+
+Params:
+
+=over
+
+=item C<cgi> - The current C<cgi> object. The search params can be altered
+using C<< $cgi->param(field, value) >>.
+
+=item C<bug_status_set> - A boolean indicating whether the status and/or
+resolution is specified in the search query entered by user.
+
+=item C<bug_product_set> - A boolean indicating whether the classification,
+product and/or component is specified in the search query entered by user.
+
+=back
+
+=head2 quicksearch_test
+
+This hook allows you to alter the QuickSearch params in the test. This has to
+correspond with the C<quicksearch_run> hook described above.
+
+Params:
+
+=over
+
+=item C<opt> - A hash of the test options containing C<params>, which has to be
+altered in the same way as C<quicksearch_run>.
+
+=back
+
=head2 sanitycheck_check
This hook allows for extra sanity checks to be added, for use by
);
# Quicksearch-wide globals for boolean charts.
-our ($chart, $and, $or, $fulltext, $bug_status_set, $ELASTIC);
+our ($chart, $and, $or, $fulltext, $bug_status_set, $bug_product_set, $ELASTIC);
sub quicksearch {
my ($searchstring) = (@_);
$cgi->param('bug_status', BUG_STATE_OPEN);
}
+ # Provide a hook to allow modifying the params
+ Bugzilla::Hook::process(
+ 'quicksearch_run',
+ {
+ 'cgi' => $cgi,
+ 'bug_status_set' => $bug_status_set,
+ 'bug_product_set' => $bug_product_set,
+ }
+ );
+
# Inform user about any unknown fields
if (scalar(@unknownFields) || scalar(keys %ambiguous_fields)) {
ThrowUserError(
if ($translated eq 'bug_status' || $translated eq 'resolution') {
$bug_status_set = 1;
}
+ if ($translated =~ /^(?:classification|product|component)$/) {
+ $bug_product_set = 1;
+ }
foreach my $value (@values) {
next unless defined $value;
my $operator
}
}
+sub quicksearch_run {
+ my ($self, $args) = @_;
+ my ($cgi, $bug_product_set) = @$args{qw(cgi bug_product_set)};
+
+ # Exclude Graveyard products by default
+ unless ($bug_product_set) {
+ $cgi->param('f1', 'classification');
+ $cgi->param('o1', 'notequals');
+ $cgi->param('v1', 'Graveyard');
+ }
+}
+
+sub quicksearch_test {
+ my ($self, $args) = @_;
+ my $opt = $args->{'opt'};
+
+ $opt->{params}->{'f1'} = 'classification';
+ $opt->{params}->{'o1'} = 'notequals';
+ $opt->{params}->{'v1'} = 'Graveyard';
+}
+
sub object_columns {
my ($self, $args) = @_;
return unless $args->{class}->isa('Bugzilla::Product');
# if there are elements in the tracking_flags array, then they have been
# removed from the query, so we mustn't generate joins
- return if scalar @{$args->{search}->{tracking_flags}};
+ return if scalar @{$args->{search}->{tracking_flags} || []};
my $column_joins = $args->{'column_joins'};
my @tracking_flags = Bugzilla::Extension::TrackingFlags::Flag->get_all;
use Bugzilla::Test::MockParams (password_complexity => 'no_constraints');
use Bugzilla;
use Bugzilla::Constants;
+use Bugzilla::Hook;
BEGIN { Bugzilla->extensions }
use Test2::V0;
use Test2::Tools::Mock qw(mock mock_accessor);
}
}
+ # Provide a hook to allow modifying the params. This has to correspond with
+ # the `quicksearch_run` hook
+ Bugzilla::Hook::process('quicksearch_test', { 'opt' => \%opt });
+
is($vars, $opt{params}, "test params: $opt{input}");
if (my $sql = $opt{sql_like}) {
my $search = Bugzilla::Search->new(params => $vars);