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 --- attachment.cgi | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'attachment.cgi') diff --git a/attachment.cgi b/attachment.cgi index c28a300a0..4f3dabd55 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -435,32 +435,14 @@ sub insert { # Validations are done later when the user submits changes. sub edit { my $attachment = validateID(); - my $dbh = Bugzilla->dbh; - # Retrieve a list of attachments for this bug as well as a summary of the bug - # to use in a navigation bar across the top of the screen. my $bugattachments = Bugzilla::Attachment->get_attachments_by_bug($attachment->bug_id); # We only want attachment IDs. @$bugattachments = map { $_->id } @$bugattachments; - my ($bugsummary, $product_id, $component_id) = - $dbh->selectrow_array('SELECT short_desc, product_id, component_id - FROM bugs - WHERE bug_id = ?', undef, $attachment->bug_id); - - # Get a list of flag types that can be set for this attachment. - my $flag_types = Bugzilla::FlagType::match({ 'target_type' => 'attachment' , - 'product_id' => $product_id , - 'component_id' => $component_id }); - foreach my $flag_type (@$flag_types) { - $flag_type->{'flags'} = Bugzilla::Flag->match({ 'type_id' => $flag_type->id, - 'attach_id' => $attachment->id }); - } - $vars->{'flag_types'} = $flag_types; - $vars->{'any_flags_requesteeble'} = grep($_->is_requesteeble, @$flag_types); + $vars->{'any_flags_requesteeble'} = grep($_->is_requesteeble, @{$attachment->flag_types}); $vars->{'attachment'} = $attachment; - $vars->{'bugsummary'} = $bugsummary; $vars->{'attachments'} = $bugattachments; print $cgi->header(); -- cgit v1.2.3-24-g4f1b