From 4dd427ea99673391d923db9682836d344f178b54 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Mon, 8 Sep 2008 21:21:24 +0000 Subject: Bug 453743: Decrease the number of calls to the DB about flags when viewing a bug - Patch by Frédéric Buclin r/a=mkanat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Bug.pm | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'Bugzilla/Bug.pm') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index d625953a9..14f781c42 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -2314,7 +2314,7 @@ sub attachments { return [] if $self->{'error'}; $self->{'attachments'} = - Bugzilla::Attachment->get_attachments_by_bug($self->bug_id); + Bugzilla::Attachment->get_attachments_by_bug($self->bug_id, {preload => 1}); return $self->{'attachments'}; } @@ -2421,22 +2421,12 @@ sub flag_types { return $self->{'flag_types'} if exists $self->{'flag_types'}; return [] if $self->{'error'}; - # The types of flags that can be set on this bug. - # If none, no UI for setting flags will be displayed. - my $flag_types = Bugzilla::FlagType::match( - {'target_type' => 'bug', - 'product_id' => $self->{'product_id'}, - 'component_id' => $self->{'component_id'} }); - - foreach my $flag_type (@$flag_types) { - $flag_type->{'flags'} = Bugzilla::Flag->match( - { 'bug_id' => $self->bug_id, - 'type_id' => $flag_type->{'id'}, - 'target_type' => 'bug' }); - } - - $self->{'flag_types'} = $flag_types; + my $vars = { target_type => 'bug', + product_id => $self->{product_id}, + component_id => $self->{component_id}, + bug_id => $self->bug_id }; + $self->{'flag_types'} = Bugzilla::Flag::_flag_types($vars); return $self->{'flag_types'}; } -- cgit v1.2.3-24-g4f1b