From: Kohei Yoshino Date: Tue, 28 May 2019 18:50:27 +0000 (-0400) Subject: Bug 1283312 - Allow searching for bugs which have had a flag value (r?, needinfo... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a045205d40c14db610679a06ea9f8521a78d176;p=thirdparty%2Fbugzilla.git Bug 1283312 - Allow searching for bugs which have had a flag value (r?, needinfo?, r-, …) set for some period of time --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index c3c627f84..09e3172a4 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -43,7 +43,6 @@ use base qw(Bugzilla::Object Exporter); @Bugzilla::Bug::EXPORT = qw( bug_alias_to_id LogActivityEntry - editable_bug_fields ); my %CLEANUP; @@ -4446,36 +4445,6 @@ sub bug_alias_to_id { # Subroutines ##################################################################### -# Returns a list of currently active and editable bug fields, -# including multi-select fields. -sub editable_bug_fields { - my @fields = Bugzilla->dbh->bz_table_columns('bugs'); - - # Add multi-select fields - push(@fields, - map { $_->name } - @{Bugzilla->fields({obsolete => 0, type => FIELD_TYPE_MULTI_SELECT})}); - - # Obsolete custom fields are not editable. - my @obsolete_fields = @{Bugzilla->fields({obsolete => 1, custom => 1})}; - @obsolete_fields = map { $_->name } @obsolete_fields; - foreach - my $remove ("bug_id", "reporter", "creation_ts", "delta_ts", "lastdiffed", - @obsolete_fields) - { - my $location = firstidx { $_ eq $remove } @fields; - - # Ensure field exists before attempting to remove it. - splice(@fields, $location, 1) if ($location > -1); - } - - Bugzilla::Hook::process('bug_editable_bug_fields', {fields => \@fields}); - - # Sorted because the old @::log_columns variable, which this replaces, - # was sorted. - return sort(@fields); -} - # Emit a list of dependencies or regressions. Join with bug_status and bugs # tables to show bugs with open statuses first, and then the others sub list_relationship { diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm index 666f35a6d..f8377437a 100644 --- a/extensions/TrackingFlags/Extension.pm +++ b/extensions/TrackingFlags/Extension.pm @@ -411,15 +411,6 @@ sub bug_create_cf_accessors { } } -sub bug_editable_bug_fields { - my ($self, $args) = @_; - my $fields = $args->{'fields'}; - my @tracking_flags = Bugzilla::Extension::TrackingFlags::Flag->get_all; - foreach my $flag (@tracking_flags) { - push(@$fields, $flag->name); - } -} - sub search_operator_field_override { my ($self, $args) = @_; my $operators = $args->{'operators'}; diff --git a/query.cgi b/query.cgi index c15575a88..92ef971e3 100755 --- a/query.cgi +++ b/query.cgi @@ -162,12 +162,22 @@ if (Bugzilla->params->{'usetargetmilestone'}) { } my @chfields; +my $search_fields = Bugzilla::Search::search_fields({obsolete => 0}); +my $uneditable_fields_re = join('|', qw( + attachments\.submitter + bug_id + commenter + creation_ts + delta_ts + lastdiffed + reporter +)); push @chfields, "[Bug creation]"; # This is what happens when you have variables whose definition depends # on the DB schema, and then the underlying schema changes... -foreach my $val (editable_bug_fields()) { +foreach my $val (keys %$search_fields) { if ($val eq 'classification_id') { $val = 'classification'; } @@ -177,6 +187,9 @@ foreach my $val (editable_bug_fields()) { elsif ($val eq 'component_id') { $val = 'component'; } + elsif ($val =~ /^(?:$uneditable_fields_re)$/) { + next; + } push @chfields, $val; } @@ -204,7 +217,7 @@ $vars->{'resolution'} # Boolean charts my @fields = sort { lc($a->description) cmp lc($b->description) } - values %{Bugzilla::Search::search_fields({obsolete => 0})}; + values %$search_fields; unshift(@fields, {name => "noop", description => "---"}); $vars->{'fields'} = \@fields;