Commit 770ba88b authored by olav%bkor.dhs.org's avatar olav%bkor.dhs.org

Bug 366629: Bugmail messed up if adding dependency for resolved bug in new bug

Patch by Olav Vitters <olav@bkor.dhs.org> r=LpSolit a=LpSolit
parent 121badd2
...@@ -215,6 +215,7 @@ sub Send { ...@@ -215,6 +215,7 @@ sub Send {
$when_restriction $when_restriction
ORDER BY bugs_activity.bug_when", undef, @args); ORDER BY bugs_activity.bug_when", undef, @args);
my @new_depbugs;
my $difftext = ""; my $difftext = "";
my $diffheader = ""; my $diffheader = "";
my @diffparts; my @diffparts;
...@@ -238,6 +239,9 @@ sub Send { ...@@ -238,6 +239,9 @@ sub Send {
$old = format_time_decimal($old); $old = format_time_decimal($old);
$new = format_time_decimal($new); $new = format_time_decimal($new);
} }
if ($fieldname eq 'dependson') {
push(@new_depbugs, grep {$_ =~ /^\d+$/} split(/[\s,]+/, $new));
}
if ($attachid) { if ($attachid) {
($diffpart->{'isprivate'}) = $dbh->selectrow_array( ($diffpart->{'isprivate'}) = $dbh->selectrow_array(
'SELECT isprivate FROM attachments WHERE attach_id = ?', 'SELECT isprivate FROM attachments WHERE attach_id = ?',
...@@ -252,9 +256,19 @@ sub Send { ...@@ -252,9 +256,19 @@ sub Send {
} }
$values{'changed_fields'} = join(' ', @changedfields); $values{'changed_fields'} = join(' ', @changedfields);
my @depbugs;
my $deptext = ""; my $deptext = "";
# Do not include data about dependent bugs when they have just been added.
# Completely skip checking for dependent bugs on bug creation as all
# dependencies bugs will just have been added.
if ($start) {
my $dep_restriction = "";
if (scalar @new_depbugs) {
$dep_restriction = "AND bugs_activity.bug_id NOT IN (" .
join(", ", @new_depbugs) . ")";
}
my $dependency_diffs = $dbh->selectall_arrayref( my $dependency_diffs = $dbh->selectall_arrayref(
"SELECT bugs_activity.bug_id, bugs.short_desc, fielddefs.name, "SELECT bugs_activity.bug_id, bugs.short_desc, fielddefs.name,
bugs_activity.removed, bugs_activity.added bugs_activity.removed, bugs_activity.added
FROM bugs_activity FROM bugs_activity
...@@ -268,52 +282,50 @@ sub Send { ...@@ -268,52 +282,50 @@ sub Send {
AND (fielddefs.name = 'bug_status' AND (fielddefs.name = 'bug_status'
OR fielddefs.name = 'resolution') OR fielddefs.name = 'resolution')
$when_restriction $when_restriction
$dep_restriction
ORDER BY bugs_activity.bug_when, bugs.bug_id", undef, @args); ORDER BY bugs_activity.bug_when, bugs.bug_id", undef, @args);
my $thisdiff = ""; my $thisdiff = "";
my $lastbug = ""; my $lastbug = "";
my $interestingchange = 0; my $interestingchange = 0;
my @depbugs; foreach my $dependency_diff (@$dependency_diffs) {
foreach my $dependency_diff (@$dependency_diffs) { my ($depbug, $summary, $what, $old, $new) = @$dependency_diff;
my ($depbug, $summary, $what, $old, $new) = @$dependency_diff;
if ($depbug ne $lastbug) { if ($depbug ne $lastbug) {
if ($interestingchange) { if ($interestingchange) {
$deptext .= $thisdiff; $deptext .= $thisdiff;
}
$lastbug = $depbug;
my $urlbase = Bugzilla->params->{"urlbase"};
$thisdiff =
"\nBug $id depends on bug $depbug, which changed state.\n\n" .
"Bug $depbug Summary: $summary\n" .
"${urlbase}show_bug.cgi?id=$depbug\n\n";
$thisdiff .= FormatTriple("What ", "Old Value", "New Value");
$thisdiff .= ('-' x 76) . "\n";
$interestingchange = 0;
} }
$lastbug = $depbug; $thisdiff .= FormatTriple($fielddescription{$what}, $old, $new);
my $urlbase = Bugzilla->params->{"urlbase"}; if ($what eq 'bug_status'
$thisdiff = && Bugzilla::Bug::is_open_state($old) ne Bugzilla::Bug::is_open_state($new))
"\nBug $id depends on bug $depbug, which changed state.\n\n" . {
"Bug $depbug Summary: $summary\n" . $interestingchange = 1;
"${urlbase}show_bug.cgi?id=$depbug\n\n"; }
$thisdiff .= FormatTriple("What ", "Old Value", "New Value"); push(@depbugs, $depbug);
$thisdiff .= ('-' x 76) . "\n";
$interestingchange = 0;
}
$thisdiff .= FormatTriple($fielddescription{$what}, $old, $new);
if ($what eq 'bug_status'
&& Bugzilla::Bug::is_open_state($old) ne Bugzilla::Bug::is_open_state($new))
{
$interestingchange = 1;
} }
push(@depbugs, $depbug);
}
if ($interestingchange) {
$deptext .= $thisdiff;
}
$deptext = trim($deptext); if ($interestingchange) {
$deptext .= $thisdiff;
}
$deptext = trim($deptext);
if ($deptext) { if ($deptext) {
my $diffpart = {}; my $diffpart = {};
$diffpart->{'text'} = "\n" . trim("\n\n" . $deptext); $diffpart->{'text'} = "\n" . trim("\n\n" . $deptext);
push(@diffparts, $diffpart); push(@diffparts, $diffpart);
}
} }
my ($raw_comments, $anyprivate, $count) = get_comments_by_bug($id, $start, $end); my ($raw_comments, $anyprivate, $count) = get_comments_by_bug($id, $start, $end);
########################################################################### ###########################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment