diff options
-rw-r--r-- | Bugzilla/Search.pm | 27 | ||||
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/Constants.pm | 12 |
2 files changed, 17 insertions, 22 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 952fc0854..fa162ed1d 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -1264,7 +1264,7 @@ sub _special_parse_bug_status { @bug_status = _valid_values(\@bug_status, $legal_statuses); # If the user has selected every status, change to selecting none. - # This is functionally equivalent, but quite a lot faster. + # This is functionally equivalent, but quite a lot faster. if ($all or scalar(@bug_status) == scalar(@$legal_statuses)) { delete $params->{'bug_status'}; } @@ -1285,6 +1285,8 @@ sub _special_parse_chfield { my $value_to = $params->{'chfieldvalue'}; $value_to = '' if !defined $value_to; + @fields = map { $_ eq '[Bug creation]' ? 'creation_ts' : $_ } @fields; + my @charts; # It is always safe and useful to push delta_ts into the charts # if there are any dates specified. It doesn't conflict with @@ -1297,15 +1299,6 @@ sub _special_parse_chfield { if ($date_to ne '') { push(@charts, ['delta_ts', 'lessthaneq', $date_to]); } - - if (grep { $_ eq '[Bug creation]' } @fields) { - if ($date_from ne '') { - push(@charts, ['creation_ts', 'greaterthaneq', $date_from]); - } - if ($date_to ne '') { - push(@charts, ['creation_ts', 'lessthaneq', $date_to]); - } - } # Basically, we construct the chart like: # @@ -1321,7 +1314,6 @@ sub _special_parse_chfield { if ($value_to ne '') { my @value_chart; foreach my $field (@fields) { - next if $field eq '[Bug creation]'; push(@value_chart, $field, 'changedto', $value_to); } push(@charts, \@value_chart) if @value_chart; @@ -1330,7 +1322,6 @@ sub _special_parse_chfield { if ($date_from ne '') { my @date_from_chart; foreach my $field (@fields) { - next if $field eq '[Bug creation]'; push(@date_from_chart, $field, 'changedafter', $date_from); } push(@charts, \@date_from_chart) if @date_from_chart; @@ -2775,10 +2766,18 @@ sub _changedbefore_changedafter { my ($chart_id, $joins, $field, $operator, $value) = @$args{qw(chart_id joins field operator value)}; my $dbh = Bugzilla->dbh; - - my $sql_operator = ($operator =~ /before/) ? '<=' : '>='; + my $field_object = $self->_chart_fields->{$field} || ThrowCodeError("invalid_field_name", { field => $field }); + + # Asking when creation_ts changed is just asking when the bug was created. + if ($field_object->name eq 'creation_ts') { + $args->{operator} = + $operator eq 'changedbefore' ? 'lessthaneq' : 'greaterthaneq'; + return $self->_do_operator_function($args); + } + + my $sql_operator = ($operator =~ /before/) ? '<=' : '>='; my $field_id = $field_object->id; # Charts on changed* fields need to be field-specific. Otherwise, # OR chart rows make no sense if they contain multiple fields. diff --git a/xt/lib/Bugzilla/Test/Search/Constants.pm b/xt/lib/Bugzilla/Test/Search/Constants.pm index abe01bbd1..7b06a0c95 100644 --- a/xt/lib/Bugzilla/Test/Search/Constants.pm +++ b/xt/lib/Bugzilla/Test/Search/Constants.pm @@ -420,13 +420,11 @@ use constant KNOWN_BROKEN => { 'changedbefore' => { CHANGED_BROKEN, 'attach_data.thedata' => { contains => [1] }, - creation_ts => { contains => [1,2,5] }, }, 'changedafter' => { 'attach_data.thedata' => { contains => [2,3,4] }, classification => { contains => [2,3,4] }, commenter => { contains => [2,3,4] }, - creation_ts => { contains => [2,3,4] }, delta_ts => { contains => [2,3,4] }, percentage_complete => { contains => [2,3,4] }, 'requestees.login_name' => { contains => [2,3,4] }, @@ -642,7 +640,6 @@ use constant BROKEN_NOT => { "attach_data.thedata" => { contains => [2, 3, 4] }, "classification" => { contains => [2, 3, 4] }, "commenter" => { contains => [2, 3, 4] }, - "creation_ts" => { contains => [2, 3, 4] }, "delta_ts" => { contains => [2, 3, 4] }, "percentage_complete" => { contains => [2, 3, 4] }, "requestees.login_name" => { contains => [2, 3, 4] }, @@ -650,7 +647,6 @@ use constant BROKEN_NOT => { }, changedbefore=> { CHANGED_BROKEN_NOT, - creation_ts => { contains => [1, 2, 5] }, work_time => { } }, changedby => { @@ -1096,7 +1092,7 @@ use constant TESTS => { { contains => [1], value => '<1-delta>', override => { CHANGED_OVERRIDE, - creation_ts => { contains => [1,2,5] }, + creation_ts => { contains => [1,5] }, blocked => { contains => [1,2] }, dependson => { contains => [1,3] }, longdesc => { contains => [1,5] }, @@ -1107,7 +1103,7 @@ use constant TESTS => { { contains => [2,3,4], value => '<2-delta>', override => { CHANGED_OVERRIDE, - creation_ts => { contains => [2,3,4] }, + creation_ts => { contains => [3,4] }, # We only change this for one bug, and it doesn't match. 'longdescs.isprivate' => { contains => [] }, # Same for everconfirmed. @@ -1200,8 +1196,8 @@ use constant INJECTION_BROKEN_FIELD => { # search => 1 means the Bugzilla::Search creation fails, but # field_ok contains fields that it does actually succeed for. use constant INJECTION_BROKEN_OPERATOR => { - changedafter => { search => 1 }, - changedbefore => { search => 1 }, + changedafter => { search => 1, field_ok => ['creation_ts'] }, + changedbefore => { search => 1, field_ok => ['creation_ts'] }, changedby => { search => 1 }, }; |