]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 632717: Limit the total number of results that a search can ever return.
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Sun, 20 Feb 2011 07:44:03 +0000 (23:44 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Sun, 20 Feb 2011 07:44:03 +0000 (23:44 -0800)
r=mkanat, a=mkanat (module owner)

Bugzilla/Config/Query.pm
Bugzilla/Search.pm
report.cgi
template/en/default/admin/params/query.html.tmpl

index 821f09fc6a702500ca069a4206583dabba66c21e..3513b12e30df86340061c7281a3f7ea03f6c0286 100644 (file)
@@ -71,8 +71,14 @@ sub get_param_list {
    name => 'specific_search_allow_empty_words',
    type => 'b',
    default => 1
-  }
-  
+  },
+
+  {
+    name => 'max_search_results',
+    type => 't',
+    default => '10000',
+    checker => \&check_numeric
+  },
   );
   return @param_list;
 }
index 224193fbc052a0da30b5a0c93ca6455f4406b66f..2bd4c06c95336c8f38a00798298713384e18257c 100644 (file)
@@ -929,6 +929,12 @@ sub _sql_limit {
     my ($self) = @_;
     my $limit = $self->_params->{limit};
     my $offset = $self->_params->{offset};
+    
+    my $max_results = Bugzilla->params->{'max_search_results'};
+    if (!$self->{allow_unlimited} && (!$limit || $limit > $max_results)) {
+        $limit = $max_results;
+    }
+    
     if (defined $offset and not defined $limit) {
         $limit = INT_MAX;
     }
index 0fbb339f3adb26ae0050aff758b556949548e9c9..60067c7afcae4d64b12c21eb74badfa546821ab5 100755 (executable)
@@ -127,8 +127,11 @@ my @axis_fields = ($row_field || EMPTY_COLUMN,
 
 # Clone the params, so that Bugzilla::Search can modify them
 my $params = new Bugzilla::CGI($cgi);
-my $search = new Bugzilla::Search('fields' => \@axis_fields, 
-                                  'params' => scalar $params->Vars);
+my $search = new Bugzilla::Search(
+    fields => \@axis_fields, 
+    params => scalar $params->Vars,
+    allow_unlimited => 1,
+);
 my $query = $search->sql;
 
 $::SIG{TERM} = 'DEFAULT';
index c5bac664190db8358a27c2145fbf8d2f6f076673..0c0ff6224bb784494a3a53db8421cc1a7bc947ff 100644 (file)
@@ -55,4 +55,9 @@
     "Whether to allow a search on the 'Simple Search' page with an empty"
     _ " 'Words' field.",
 
+  max_search_results =>
+    "The maximum number of $terms.bugs that a search can"
+    _ " <strong>ever</strong> return. Tabular and graphical reports"
+    _ " are exempted from this limit, however."
+
 } %]