From: Dylan William Hardison Date: Tue, 20 Nov 2018 16:00:54 +0000 (-0500) Subject: Bug 1508695 - Incorrect or missing tracking flags on search results in REST API X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ae859a1d5b752162d89f1fdd7273d69e1245bda;p=thirdparty%2Fbugzilla.git Bug 1508695 - Incorrect or missing tracking flags on search results in REST API Note that passing bug_id to active_custom_flags() means you can get inactive flags, and as a result we should avoid caching the results when bug_id is passed. Note the part of the code ultimately using the bug id is `Bugzilla::Extension::TrackingFlags::Flag::preload_all_the_things` --- diff --git a/Bugzilla.pm b/Bugzilla.pm index 8cf77d8dc..5bc9372cc 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -638,16 +638,21 @@ sub fields { sub active_custom_fields { my (undef, $params) = @_; my $cache_id = 'active_custom_fields'; + my $can_cache = ! exists $params->{bug_id}; if ($params) { $cache_id .= ($params->{product} ? '_p' . $params->{product}->id : '') . ($params->{component} ? '_c' . $params->{component}->id : ''); $cache_id .= ':noext' if $params->{skip_extensions}; } - if (!exists request_cache->{$cache_id}) { + if (!$can_cache || !exists request_cache->{$cache_id}) { my $fields = Bugzilla::Field->match({ custom => 1, obsolete => 0, skip_extensions => 1 }); Bugzilla::Hook::process('active_custom_fields', { fields => \$fields, params => $params }); - request_cache->{$cache_id} = $fields; + if ($can_cache) { + request_cache->{$cache_id} = $fields; + } else { + return @$fields; + } } return @{request_cache->{$cache_id}}; }