diff options
-rw-r--r-- | Bugzilla/Search.pm | 6 | ||||
-rw-r--r-- | extensions/TrackingFlags/Extension.pm | 17 |
2 files changed, 22 insertions, 1 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index f51a12372..bb94cad47 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -1668,7 +1668,11 @@ sub _params_to_data_structure { # And then process the modern "custom search" format. $clause->add( $self->_custom_search ); - + + # BMO - allow post-processing of search clauses + Bugzilla::Hook::process('search_clause_structure', + { search => $self, clause => $clause }); + return $clause; } diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm index 426ab9065..84250859c 100644 --- a/extensions/TrackingFlags/Extension.pm +++ b/extensions/TrackingFlags/Extension.pm @@ -402,6 +402,23 @@ sub search_operator_field_override { } } +sub search_clause_structure { + my ($self, $args) = @_; + # when searching, map "eq ---" to "isempty" + my $clause = $args->{clause}; + my @tracking_flags = map { $_->name } Bugzilla::Extension::TrackingFlags::Flag->get_all; + $clause->walk_conditions(sub { + my ($clause, $condition) = @_; + if (grep { $condition->field eq $_ } @tracking_flags + and $condition->{value} eq '---') + { + $condition->{operator} = $condition->{operator} =~ /^not/ + ? 'isnotempty' + : 'isempty'; + } + }); +} + sub _tracking_flags_search_nonchanged { my ($flag_id, $search, $args) = @_; my ($bugs_table, $chart_id, $joins, $value, $operator) = |