]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 552167: show_bug.cgi loads flagtypes from the database for each attachment
authorFrédéric Buclin <LpSolit@gmail.com>
Tue, 30 Mar 2010 21:46:43 +0000 (23:46 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 30 Mar 2010 21:46:43 +0000 (23:46 +0200)
r=mkanat a=LpSolit

Bugzilla/Flag.pm

index 9f900269ef49c431a50f726b95aadbb152e058ce..2073201d7a1af40d54a563cf6d88b9f5a09a6428 100644 (file)
@@ -54,6 +54,7 @@ whose names start with _ or a re specifically noted as being private.
 =cut
 
 use Scalar::Util qw(blessed);
+use Storable qw(dclone);
 
 use Bugzilla::FlagType;
 use Bugzilla::Hook;
@@ -1044,7 +1045,9 @@ sub _flag_types {
     }
 
     # Get all available flag types for the given product and component.
-    my $flag_types = Bugzilla::FlagType::match($vars);
+    my $cache = Bugzilla->request_cache->{flag_types_per_component}->{$vars->{target_type}} ||= {};
+    my $flag_data = $cache->{$vars->{component_id}} ||= Bugzilla::FlagType::match($vars);
+    my $flag_types = dclone($flag_data);
 
     $_->{flags} = [] foreach @$flag_types;
     my %flagtypes = map { $_->id => $_ } @$flag_types;
@@ -1054,8 +1057,7 @@ sub _flag_types {
     # or component).
     @$flags = grep { exists $flagtypes{$_->type_id} } @$flags;
     push(@{$flagtypes{$_->type_id}->{flags}}, $_) foreach @$flags;
-
-    return [sort {$a->sortkey <=> $b->sortkey || $a->name cmp $b->name} values %flagtypes];
+    return $flag_types;
 }
 
 =head1 SEE ALSO