From b8566e4d8f5bc2df8b90c857a99c0f5c0beaebd8 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Wed, 2 Mar 2011 00:43:43 -0800 Subject: Bug 632718: Only return 500 search results unless the user specifically requests to see more. r=dkl, a=mkanat --- Bugzilla/Config/Query.pm | 7 +++++ Bugzilla/Search.pm | 2 +- buglist.cgi | 11 ++++++++ template/en/default/admin/params/query.html.tmpl | 11 +++++++- template/en/default/list/list.html.tmpl | 36 ++++++++++++++++-------- 5 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Bugzilla/Config/Query.pm b/Bugzilla/Config/Query.pm index 3513b12e3..17a74998e 100644 --- a/Bugzilla/Config/Query.pm +++ b/Bugzilla/Config/Query.pm @@ -73,6 +73,13 @@ sub get_param_list { default => 1 }, + { + name => 'default_search_limit', + type => 't', + default => '500', + checker => \&check_numeric + }, + { name => 'max_search_results', type => 't', diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index edb59e40e..81b459ee5 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -920,7 +920,7 @@ sub _sql_limit { $limit = $max_results; } - if (defined $offset and not defined $limit) { + if (defined($offset) && !$limit) { $limit = INT_MAX; } if (defined $limit) { diff --git a/buglist.cgi b/buglist.cgi index 85162ff56..69c4edaec 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -776,6 +776,14 @@ if ($fulltext and grep { /^relevance/ } @orderstrings) { $vars->{'message'} = 'buglist_sorted_by_relevance' } +# In the HTML interface, by default, we limit the returned results, +# which speeds up quite a few searches where people are really only looking +# for the top results. +if ($format->{'extension'} eq 'html' && !defined $cgi->param('limit')) { + $params->param('limit', Bugzilla->params->{'default_search_limit'}); + $vars->{'default_limited'} = 1; +} + # Generate the basic SQL query that will be used to generate the bug list. my $search = new Bugzilla::Search('fields' => \@selectcolumns, 'params' => scalar $params->Vars, @@ -783,6 +791,9 @@ my $search = new Bugzilla::Search('fields' => \@selectcolumns, my $query = $search->sql; $vars->{'search_description'} = $search->search_description; +# We don't want saved searches and other buglist things to save +# our default limit. +$params->delete('limit') if $vars->{'default_limited'}; ################################################################################ # Query Execution diff --git a/template/en/default/admin/params/query.html.tmpl b/template/en/default/admin/params/query.html.tmpl index 0c0ff6224..d8f5f0c42 100644 --- a/template/en/default/admin/params/query.html.tmpl +++ b/template/en/default/admin/params/query.html.tmpl @@ -55,9 +55,18 @@ "Whether to allow a search on the 'Simple Search' page with an empty" _ " 'Words' field.", + default_search_limit => + "By default, $terms.Bugzilla limits searches done in the web" + _ " interface to returning only this many results, for performance" + _ " reasons. (This only affects the HTML format of search results--CSV," + _ " XML, and other formats are exempted.) Users can click a link on the" + _ " search result page to see all the results." + _ "

Usually you should not have to change this--the default value" + _ " should be acceptable for almost most installations.

", + max_search_results => "The maximum number of $terms.bugs that a search can" _ " ever return. Tabular and graphical reports" - _ " are exempted from this limit, however." + _ " are exempted from this limit, however.", } %] diff --git a/template/en/default/list/list.html.tmpl b/template/en/default/list/list.html.tmpl index a669aecb9..15184d06b 100644 --- a/template/en/default/list/list.html.tmpl +++ b/template/en/default/list/list.html.tmpl @@ -110,9 +110,7 @@ [%############################################################################%] [% IF bugs.size > 9 %] - - [% bugs.size %] [%+ terms.bugs %] found. - + [% PROCESS num_results %] [% END %] [%############################################################################%] @@ -134,15 +132,7 @@ [%# Succeeding Status Line #%] [%############################################################################%] - - [% IF bugs.size == 0 %] - [% terms.zeroSearchResults %]. - [% ELSIF bugs.size == 1 %] - One [% terms.bug %] found. - [% ELSE %] - [% bugs.size %] [%+ terms.bugs %] found. - [% END %] - +[% PROCESS num_results %] [% IF bugs.size == 0 %]