]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1508695 - Incorrect or missing tracking flags on search results in REST API
authorDylan William Hardison <dylan@hardison.net>
Tue, 20 Nov 2018 16:00:54 +0000 (11:00 -0500)
committerGitHub <noreply@github.com>
Tue, 20 Nov 2018 16:00:54 +0000 (11:00 -0500)
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`

Bugzilla.pm

index 8cf77d8dc7e4e9dbfb42851729788ad9a3dbeca7..5bc9372cc9cda2ecd1e2acc43b1cafbf42922a46 100644 (file)
@@ -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}};
 }