diff options
author | Byron Jones <bjones@mozilla.com> | 2013-05-06 08:21:29 +0200 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-05-06 08:21:29 +0200 |
commit | e99876edf0c74a0924856ba7e7f988457b18478b (patch) | |
tree | 3f10e4b0618307849d3b271a964b1e48b00b55d0 | |
parent | b4410eb57d8e07de23de18b6375039c47e6cea35 (diff) | |
parent | 00580923eb02b98581d9b4fc24f22fcaaf15b5a0 (diff) | |
download | bugzilla-e99876edf0c74a0924856ba7e7f988457b18478b.tar.gz bugzilla-e99876edf0c74a0924856ba7e7f988457b18478b.tar.xz |
merge with bugzilla/4.2
-rw-r--r-- | Bugzilla/WebService/Bug.pm | 56 | ||||
-rw-r--r-- | Bugzilla/WebService/Constants.pm | 3 | ||||
-rwxr-xr-x | report.cgi | 3 |
3 files changed, 50 insertions, 12 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 5c756b81a..f087e3207 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -420,14 +420,25 @@ sub history { sub search { my ($self, $params) = @_; - + Bugzilla->switch_to_shadow_db(); if ( defined($params->{offset}) and !defined($params->{limit}) ) { ThrowCodeError('param_required', { param => 'limit', function => 'Bug.search()' }); } - + + my $max_results = Bugzilla->params->{max_search_results}; + unless (defined $params->{limit} && $params->{limit} == 0) { + if (!defined $params->{limit} || $params->{limit} > $max_results) { + $params->{limit} = $max_results; + } + } + else { + delete $params->{limit}; + delete $params->{offset}; + } + $params = Bugzilla::Bug::map_fields($params); delete $params->{WHERE}; @@ -454,7 +465,17 @@ sub search { my $clause = join(' OR ', @likes); $params->{WHERE}->{"($clause)"} = [map { "\%$_\%" } @strings]; } - + + # If no other parameters have been passed other than limit and offset + # and a WHERE parameter was not created earlier, then we throw error + # if system is configured to do so. + if (!$params->{WHERE} + && !grep(!/(limit|offset)/i, keys %$params) + && !Bugzilla->params->{search_allow_no_criteria}) + { + ThrowUserError('buglist_parameters_required'); + } + # We want include_fields and exclude_fields to be passed to # _bug_to_hash but not to Bugzilla::Bug->match so we copy the # params and delete those before passing to Bugzilla::Bug->match. @@ -2289,13 +2310,16 @@ May not be an array. =item C<limit> -C<int> Limit the number of results returned to C<int> records. +C<int> Limit the number of results returned to C<int> records. If the limit +is more than zero and higher than the maximum limit set by the administrator, +then the maximum limit will be used instead. If you set the limit equal to zero, +then all matching results will be returned instead. =item C<offset> -C<int> Used in conjunction with the C<limit> argument, C<offset> defines -the starting position for the search. For example, given a search that -would return 100 bugs, setting C<limit> to 10 and C<offset> to 10 would return +C<int> Used in conjunction with the C<limit> argument, C<offset> defines +the starting position for the search. For example, given a search that +would return 100 bugs, setting C<limit> to 10 and C<offset> to 10 would return bugs 11 through 20 from the set of 100. =item C<op_sys> @@ -2386,10 +2410,16 @@ log in and I<then> call this method. =item B<Errors> -Currently, this function doesn't throw any special errors (other than -the ones that all webservice functions can throw). If you specify -an invalid value for a particular field, you just won't get any results -for that value. +If you specify an invalid value for a particular field, you just won't +get any results for that value. + +=over + +=item 1000 (Parameters Required) + +You may not search without any search terms. + +=back =item B<History> @@ -2402,6 +2432,10 @@ for that value. =item The C<reporter> input parameter was renamed to C<creator> in Bugzilla B<4.0>. +=item In B<4.2.6> and newer, added the ability to return all results if +C<limit> is set equal to zero. Otherwise maximum results returned are limited +by system configuration. + =back =back diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm index 6274c3a78..3207356fa 100644 --- a/Bugzilla/WebService/Constants.pm +++ b/Bugzilla/WebService/Constants.pm @@ -168,6 +168,9 @@ use constant WS_ERROR_CODE => { invalid_regexp => 803, invalid_group_name => 804, + # Search errors are 1000-1100 + buglist_parameters_required => 1000, + # Errors thrown by the WebService itself. The ones that are negative # conform to http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php xmlrpc_invalid_value => -32600, diff --git a/report.cgi b/report.cgi index decbaeeb2..4e8689527 100755 --- a/report.cgi +++ b/report.cgi @@ -321,7 +321,7 @@ sub get_names { foreach my $value (@{$field->legal_values}) { push(@sorted, $value->name) if $names->{$value->name}; } - unshift(@sorted, ' ') if $field_name eq 'resolution'; + unshift(@sorted, '---') if $field_name eq 'resolution'; @sorted = uniq @sorted; } elsif ($isnumeric) { @@ -350,6 +350,7 @@ sub check_value { else { $value = shift @$result; $value = ' ' if (!defined $value || $value eq ''); + $value = '---' if ($field eq 'resolution' && $value eq ' '); } return $value; } |