From ca57713d6667e2f1a983e75c63c860658954952c Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 12 Oct 2020 16:58:49 -0400 Subject: [PATCH] Bug 1670226 - changes to cf_crash_signature not reported by bugzilla's API --- .gitignore | 1 + Bugzilla/WebService/Bug.pm | 2 +- extensions/BMO/Extension.pm | 13 ++++++++++++- .../template/en/default/bug_modal/edit.html.tmpl | 2 +- extensions/Ember/lib/WebService.pm | 2 +- extensions/TrackingFlags/lib/Flag.pm | 2 ++ template/en/default/bug/show-multiple.html.tmpl | 2 +- 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 22feba92e8..6a3fc41c57 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ __lbheartbeat__ /skins/contrib/Dusk/admin.css /skins/contrib/Dusk/bug.css +.vstags diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 5309f8bb14..185ef904ca 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -1607,7 +1607,7 @@ sub _bug_to_hash { { product => $bug->product_obj, component => $bug->component_obj, - bug_id => $bug->id + bug => $bug }, $self->wants_object, ); diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index 8c034e4884..8ce86e4268 100755 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -441,6 +441,7 @@ sub active_custom_fields { my $params = $args->{'params'}; my $product = $params->{'product'}; my $component = $params->{'component'}; + my $bug = $params->{'bug'}; return if !$product; @@ -449,7 +450,7 @@ sub active_custom_fields { my @tmp_fields; foreach my $field (@$$fields) { - next if cf_hidden_in_product($field->name, $product_name, $component_name); + next if cf_hidden_in_product($field->name, $product_name, $component_name, $bug); push(@tmp_fields, $field); } $$fields = \@tmp_fields; @@ -458,6 +459,16 @@ sub active_custom_fields { sub cf_hidden_in_product { my ($field_name, $product_name, $component_name, $bug) = @_; + # Show field if a value has been set + my $value; + if (blessed($bug) && $bug->can($field_name)) { + $value = $bug->$field_name; + } + else { + $value = $bug->{$field_name}; + } + return 0 if $value && $value ne '---'; + # check Bugzilla's built-in visibility controls first if ($bug) { my $field = Bugzilla::Field->new({name => $field_name, cache => 1}); diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl index 504dbcd1ae..fa2c18fce3 100755 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -29,7 +29,7 @@ ]; # all custom fields - custom_fields = Bugzilla.active_custom_fields(product => bug.product_obj, component => bug.component_obj, bug_id => bug.id); + custom_fields = Bugzilla.active_custom_fields(product => bug.product_obj, component => bug.component_obj, bug => bug); # extract needinfo flags needinfo = []; diff --git a/extensions/Ember/lib/WebService.pm b/extensions/Ember/lib/WebService.pm index 1c1b35aea7..a433f3bac7 100644 --- a/extensions/Ember/lib/WebService.pm +++ b/extensions/Ember/lib/WebService.pm @@ -361,7 +361,7 @@ sub _get_fields { # Load custom fields my $cf_params = {product => $bug->product_obj}; $cf_params->{component} = $bug->component_obj if $bug->can('component_obj'); - $cf_params->{bug_id} = $bug->id if $bug->id; + $cf_params->{bug} = $bug if $bug; push(@field_objs, Bugzilla->active_custom_fields($cf_params)); } diff --git a/extensions/TrackingFlags/lib/Flag.pm b/extensions/TrackingFlags/lib/Flag.pm index 5a09d944fe..3d8c29e258 100644 --- a/extensions/TrackingFlags/lib/Flag.pm +++ b/extensions/TrackingFlags/lib/Flag.pm @@ -184,6 +184,8 @@ sub match { # Use later for preload my $bug_id = delete $params->{'bug_id'}; + my $bug = delete $params->{'bug'}; + $bug_id = $bug->id if $bug; # Retrieve all flags relevant for the given product and component if ( diff --git a/template/en/default/bug/show-multiple.html.tmpl b/template/en/default/bug/show-multiple.html.tmpl index 43be970a75..20088d6284 100644 --- a/template/en/default/bug/show-multiple.html.tmpl +++ b/template/en/default/bug/show-multiple.html.tmpl @@ -193,7 +193,7 @@ [% USE Bugzilla %] [% field_counter = 0 %] - [% FOREACH field = Bugzilla.active_custom_fields(product=>bug.product_obj,component=>bug.component_obj,bug_id=>bug.id) %] + [% FOREACH field = Bugzilla.active_custom_fields(product=>bug.product_obj,component=>bug.component_obj,bug=>bug) %] [% field_counter = field_counter + 1 %] [%# Odd-numbered fields get an opening %] [% '' IF field_counter % 2 %]