Skip to content

Commit 940d3fa

Browse files
committed
Bug 1082887: comments made when setting a flag from the attachment details page are not included in the "flag updated" email
r=dkl,a=glob
1 parent 42d5e45 commit 940d3fa

File tree

1 file changed

+59
-53
lines changed

1 file changed

+59
-53
lines changed

attachment.cgi

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ sub insert {
540540
my ($flags, $new_flags) = Bugzilla::Flag->extract_flags_from_cgi(
541541
$bug, $attachment, $vars, SKIP_REQUESTEE_ON_ERROR);
542542
$attachment->set_flags($flags, $new_flags);
543-
$attachment->update($timestamp);
544543

545544
# Insert a comment about the new attachment into the database.
546545
my $comment = $cgi->param('comment');
@@ -549,71 +548,76 @@ sub insert {
549548
type => CMT_ATTACHMENT_CREATED,
550549
extra_data => $attachment->id });
551550

552-
# Assign the bug to the user, if they are allowed to take it
553-
my $owner = "";
554-
if ($cgi->param('takebug') && $user->in_group('editbugs', $bug->product_id)) {
555-
# When taking a bug, we have to follow the workflow.
556-
my $bug_status = $cgi->param('bug_status') || '';
557-
($bug_status) = grep {$_->name eq $bug_status} @{$bug->status->can_change_to};
558-
559-
if ($bug_status && $bug_status->is_open
560-
&& ($bug_status->name ne 'UNCONFIRMED'
561-
|| $bug->product_obj->allows_unconfirmed))
562-
{
563-
$bug->set_bug_status($bug_status->name);
564-
$bug->clear_resolution();
565-
}
566-
# Make sure the person we are taking the bug from gets mail.
567-
$owner = $bug->assigned_to->login;
568-
$bug->set_assigned_to($user);
569-
}
551+
# Assign the bug to the user, if they are allowed to take it
552+
my $owner = "";
553+
if ($cgi->param('takebug') && $user->in_group('editbugs', $bug->product_id)) {
554+
# When taking a bug, we have to follow the workflow.
555+
my $bug_status = $cgi->param('bug_status') || '';
556+
($bug_status) = grep { $_->name eq $bug_status }
557+
@{ $bug->status->can_change_to };
558+
559+
if ($bug_status && $bug_status->is_open
560+
&& ($bug_status->name ne 'UNCONFIRMED'
561+
|| $bug->product_obj->allows_unconfirmed))
562+
{
563+
$bug->set_bug_status($bug_status->name);
564+
$bug->clear_resolution();
565+
}
566+
# Make sure the person we are taking the bug from gets mail.
567+
$owner = $bug->assigned_to->login;
568+
$bug->set_assigned_to($user);
569+
}
570+
571+
$bug->add_cc($user) if $cgi->param('addselfcc');
572+
$bug->update($timestamp);
570573

571-
$bug->add_cc($user) if $cgi->param('addselfcc');
572-
$bug->update($timestamp);
574+
# We have to update the attachment after updating the bug, to ensure new
575+
# comments are available.
576+
$attachment->update($timestamp);
573577

574-
$dbh->bz_commit_transaction;
578+
$dbh->bz_commit_transaction;
575579

576-
# Define the variables and functions that will be passed to the UI template.
577-
$vars->{'attachment'} = $attachment;
578-
# We cannot reuse the $bug object as delta_ts has eventually been updated
579-
# since the object was created.
580-
$vars->{'bugs'} = [new Bugzilla::Bug($bugid)];
581-
$vars->{'header_done'} = 1;
582-
$vars->{'contenttypemethod'} = $cgi->param('contenttypemethod');
580+
# Define the variables and functions that will be passed to the UI template.
581+
$vars->{'attachment'} = $attachment;
582+
# We cannot reuse the $bug object as delta_ts has eventually been updated
583+
# since the object was created.
584+
$vars->{'bugs'} = [new Bugzilla::Bug($bugid)];
585+
$vars->{'header_done'} = 1;
586+
$vars->{'contenttypemethod'} = $cgi->param('contenttypemethod');
583587

584-
my $recipients = { 'changer' => $user, 'owner' => $owner };
585-
$vars->{'sent_bugmail'} = Bugzilla::BugMail::Send($bugid, $recipients);
588+
my $recipients = { 'changer' => $user, 'owner' => $owner };
589+
$vars->{'sent_bugmail'} = Bugzilla::BugMail::Send($bugid, $recipients);
586590

587-
print $cgi->header();
588-
# Generate and return the UI (HTML page) from the appropriate template.
589-
$template->process("attachment/created.html.tmpl", $vars)
590-
|| ThrowTemplateError($template->error());
591+
print $cgi->header();
592+
# Generate and return the UI (HTML page) from the appropriate template.
593+
$template->process("attachment/created.html.tmpl", $vars)
594+
|| ThrowTemplateError($template->error());
591595
}
592596

593597
# Displays a form for editing attachment properties.
594598
# Any user is allowed to access this page, unless the attachment
595599
# is private and the user does not belong to the insider group.
596600
# Validations are done later when the user submits changes.
597601
sub edit {
598-
my $attachment = validateID();
602+
my $attachment = validateID();
599603

600-
my $bugattachments =
601-
Bugzilla::Attachment->get_attachments_by_bug($attachment->bug);
604+
my $bugattachments =
605+
Bugzilla::Attachment->get_attachments_by_bug($attachment->bug);
602606

603-
my $any_flags_requesteeble =
604-
grep { $_->is_requestable && $_->is_requesteeble } @{$attachment->flag_types};
605-
# Useful in case a flagtype is no longer requestable but a requestee
606-
# has been set before we turned off that bit.
607-
$any_flags_requesteeble ||= grep { $_->requestee_id } @{$attachment->flags};
608-
$vars->{'any_flags_requesteeble'} = $any_flags_requesteeble;
609-
$vars->{'attachment'} = $attachment;
610-
$vars->{'attachments'} = $bugattachments;
607+
my $any_flags_requesteeble = grep { $_->is_requestable && $_->is_requesteeble }
608+
@{ $attachment->flag_types };
609+
# Useful in case a flagtype is no longer requestable but a requestee
610+
# has been set before we turned off that bit.
611+
$any_flags_requesteeble ||= grep { $_->requestee_id } @{ $attachment->flags };
612+
$vars->{'any_flags_requesteeble'} = $any_flags_requesteeble;
613+
$vars->{'attachment'} = $attachment;
614+
$vars->{'attachments'} = $bugattachments;
611615

612-
print $cgi->header();
616+
print $cgi->header();
613617

614-
# Generate and return the UI (HTML page) from the appropriate template.
615-
$template->process("attachment/edit.html.tmpl", $vars)
616-
|| ThrowTemplateError($template->error());
618+
# Generate and return the UI (HTML page) from the appropriate template.
619+
$template->process("attachment/edit.html.tmpl", $vars)
620+
|| ThrowTemplateError($template->error());
617621
}
618622

619623
# Updates an attachment record. Only users with "editbugs" privileges,
@@ -715,16 +719,18 @@ sub update {
715719
# Figure out when the changes were made.
716720
my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
717721

722+
# Commit the comment, if any.
723+
# This has to happen before updating the attachment, to ensure new comments
724+
# are available to $attachment->update.
725+
$bug->update($timestamp);
726+
718727
if ($can_edit) {
719728
my $changes = $attachment->update($timestamp);
720729
# If there are changes, we updated delta_ts in the DB. We have to
721730
# reflect this change in the bug object.
722731
$bug->{delta_ts} = $timestamp if scalar(keys %$changes);
723732
}
724733

725-
# Commit the comment, if any.
726-
$bug->update($timestamp);
727-
728734
# Commit the transaction now that we are finished updating the database.
729735
$dbh->bz_commit_transaction();
730736

0 commit comments

Comments
 (0)