From fa9d1a7629786335d2683b28096cc440f5f24d49 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" Date: Mon, 15 Aug 2005 18:48:14 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20304642:=20Bugzilla::Flag::GetTarget()=20s?= =?UTF-8?q?hould=20be=20called=20internally=20by=20Bugzilla::Flag::process?= =?UTF-8?q?()=20-=20Patch=20by=20Fr=EF=BF=BDd=EF=BF=BDric=20Buclin=20=20r/a=3Dmyk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webtools/bugzilla/Bugzilla/Flag.pm | 15 ++++++++------- webtools/bugzilla/attachment.cgi | 6 ++---- webtools/bugzilla/process_bug.cgi | 3 +-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/webtools/bugzilla/Bugzilla/Flag.pm b/webtools/bugzilla/Bugzilla/Flag.pm index 6c5adf440bf8..4c4864ea7762 100644 --- a/webtools/bugzilla/Bugzilla/Flag.pm +++ b/webtools/bugzilla/Bugzilla/Flag.pm @@ -414,11 +414,12 @@ used to obtain the flag fields that the user submitted. =cut sub process { - my ($target, $timestamp, $cgi) = @_; + my ($bug_id, $attach_id, $timestamp, $cgi) = @_; my $dbh = Bugzilla->dbh; - my $bug_id = $target->{'bug'}->{'id'}; - my $attach_id = $target->{'attachment'}->{'id'}; + my $target = get_target($bug_id, $attach_id); + # Make sure the target exists. + return unless $target->{'exists'}; # Use the date/time we were given if possible (allowing calling code # to synchronize the comment's timestamp with those of other records). @@ -742,7 +743,7 @@ sub FormToNewFlags { my @type_ids = map(/^flag_type-(\d+)$/ ? $1 : (), $cgi->param()); @type_ids = grep($cgi->param("flag_type-$_") ne 'X', @type_ids); - return () unless (scalar(@type_ids) && $target->{'exists'}); + return () unless scalar(@type_ids); # Get information about the setter to add to each flag. my $setter = new Bugzilla::User($::userid); @@ -846,7 +847,7 @@ sub GetBug { =over -=item C +=item C Someone please document this function. @@ -854,7 +855,7 @@ Someone please document this function. =cut -sub GetTarget { +sub get_target { my ($bug_id, $attach_id) = @_; # Create an object representing the target bug/attachment. @@ -1038,7 +1039,7 @@ sub perlify_record { exists => $exists , id => $id , type => Bugzilla::FlagType::get($type_id) , - target => GetTarget($bug_id, $attach_id) , + target => get_target($bug_id, $attach_id) , requestee => $requestee_id ? new Bugzilla::User($requestee_id) : undef, setter => new Bugzilla::User($setter_id) , status => $status , diff --git a/webtools/bugzilla/attachment.cgi b/webtools/bugzilla/attachment.cgi index ea04e2c19902..fba504690547 100755 --- a/webtools/bugzilla/attachment.cgi +++ b/webtools/bugzilla/attachment.cgi @@ -1054,8 +1054,7 @@ sub insert } # Create flags. - my $target = Bugzilla::Flag::GetTarget(undef, $attachid); - Bugzilla::Flag::process($target, $timestamp, $cgi); + Bugzilla::Flag::process($bugid, $attachid, $timestamp, $cgi); # Define the variables and functions that will be passed to the UI template. $vars->{'mailrecipients'} = { 'changer' => Bugzilla->user->login, @@ -1203,8 +1202,7 @@ sub update # to attachments so that we can delete pending requests if the user # is obsoleting this attachment without deleting any requests # the user submits at the same time. - my $target = Bugzilla::Flag::GetTarget(undef, $attach_id); - Bugzilla::Flag::process($target, $timestamp, $cgi); + Bugzilla::Flag::process($bugid, $attach_id, $timestamp, $cgi); # Update the attachment record in the database. SendSQL("UPDATE attachments diff --git a/webtools/bugzilla/process_bug.cgi b/webtools/bugzilla/process_bug.cgi index b330615ce422..b0decb861ab4 100755 --- a/webtools/bugzilla/process_bug.cgi +++ b/webtools/bugzilla/process_bug.cgi @@ -1737,8 +1737,7 @@ foreach my $id (@idlist) { } } # Set and update flags. - my $target = Bugzilla::Flag::GetTarget($id); - Bugzilla::Flag::process($target, $timestamp, $cgi); + Bugzilla::Flag::process($id, undef, $timestamp, $cgi); if ($bug_changed) { SendSQL("UPDATE bugs SET delta_ts = $sql_timestamp WHERE bug_id = $id");