Commit b4c91ada authored by Reed Loden's avatar Reed Loden

Bug 395451 - "Bugzilla::BugMail needs to use Bug objects internally instead of direct SQL"

[r=mkanat a=mkanat]
parent 2ca283e7
...@@ -90,6 +90,7 @@ sub DB_COLUMNS { ...@@ -90,6 +90,7 @@ sub DB_COLUMNS {
delta_ts delta_ts
estimated_time estimated_time
everconfirmed everconfirmed
lastdiffed
op_sys op_sys
priority priority
product_id product_id
...@@ -2612,6 +2613,11 @@ sub blocked { ...@@ -2612,6 +2613,11 @@ sub blocked {
# Even bugs in an error state always have a bug_id. # Even bugs in an error state always have a bug_id.
sub bug_id { $_[0]->{'bug_id'}; } sub bug_id { $_[0]->{'bug_id'}; }
sub bug_group {
my ($self) = @_;
return join(', ', (map { $_->name } @{$self->groups_in}));
}
sub related_bugs { sub related_bugs {
my ($self, $relationship) = @_; my ($self, $relationship) = @_;
return [] if $self->{'error'}; return [] if $self->{'error'};
...@@ -3586,7 +3592,8 @@ sub _validate_attribute { ...@@ -3586,7 +3592,8 @@ sub _validate_attribute {
qw(error groups product_id component_id qw(error groups product_id component_id
comments milestoneurl attachments isopened comments milestoneurl attachments isopened
flag_types num_attachment_flag_types flag_types num_attachment_flag_types
show_attachment_flags any_flags_requesteeble), show_attachment_flags any_flags_requesteeble
lastdiffed),
# Bug fields. # Bug fields.
Bugzilla::Bug->fields Bugzilla::Bug->fields
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# J. Paul Reed <preed@sigkill.com> # J. Paul Reed <preed@sigkill.com>
# Gervase Markham <gerv@gerv.net> # Gervase Markham <gerv@gerv.net>
# Byron Jones <bugzilla@glob.com.au> # Byron Jones <bugzilla@glob.com.au>
# Reed Loden <reed@reedloden.com>
use strict; use strict;
...@@ -110,121 +111,42 @@ sub relationships { ...@@ -110,121 +111,42 @@ sub relationships {
sub Send { sub Send {
my ($id, $forced) = (@_); my ($id, $forced) = (@_);
my @headerlist;
my %defmailhead;
my %fielddescription;
my $msg = "";
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $bug = new Bugzilla::Bug($id); my $bug = new Bugzilla::Bug($id);
# XXX - These variables below are useless. We could use field object # Only used for headers in bugmail for new bugs
# methods directly. But we first have to implement a cache in my @fields = Bugzilla->get_fields({obsolete => 0, in_new_bugmail => 1});
# Bugzilla->get_fields to avoid querying the DB all the time.
foreach my $field (Bugzilla->get_fields({obsolete => 0})) {
push(@headerlist, $field->name);
$defmailhead{$field->name} = $field->in_new_bugmail;
$fielddescription{$field->name} = $field->description;
}
my %values = %{$dbh->selectrow_hashref(
'SELECT ' . join(',', editable_bug_fields()) . ', reporter,
lastdiffed AS start_time, LOCALTIMESTAMP(0) AS end_time
FROM bugs WHERE bug_id = ?',
undef, $id)};
my $product = new Bugzilla::Product($values{product_id}); my $start = $bug->lastdiffed;
$values{product} = $product->name; my $end = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
if (Bugzilla->params->{'useclassification'}) {
$values{classification} = Bugzilla::Classification->new($product->classification_id)->name;
}
my $component = new Bugzilla::Component($values{component_id});
$values{component} = $component->name;
my ($start, $end) = ($values{start_time}, $values{end_time});
# User IDs of people in various roles. More than one person can 'have' a # Bugzilla::User objects of people in various roles. More than one person
# role, if the person in that role has changed, or people are watching. # can 'have' a role, if the person in that role has changed, or people are
my $reporter = $values{'reporter'}; # watching.
my @assignees = ($values{'assigned_to'}); my @assignees = ($bug->assigned_to);
my @qa_contacts = ($values{'qa_contact'}); my @qa_contacts = ($bug->qa_contact);
my $cc_users = $dbh->selectall_arrayref( my @ccs = @{ $bug->cc_users };
"SELECT cc.who, profiles.login_name
FROM cc
INNER JOIN profiles
ON cc.who = profiles.userid
WHERE bug_id = ?",
undef, $id);
my (@ccs, @cc_login_names);
foreach my $cc_user (@$cc_users) {
my ($user_id, $user_login) = @$cc_user;
push (@ccs, $user_id);
push (@cc_login_names, $user_login);
}
# Include the people passed in as being in particular roles. # Include the people passed in as being in particular roles.
# This can include people who used to hold those roles. # This can include people who used to hold those roles.
# At this point, we don't care if there are duplicates in these arrays. # At this point, we don't care if there are duplicates in these arrays.
my $changer = $forced->{'changer'}; my $changer = $forced->{'changer'};
if ($forced->{'owner'}) { if ($forced->{'owner'}) {
push (@assignees, login_to_id($forced->{'owner'}, THROW_ERROR)); push (@assignees, Bugzilla::User->check($forced->{'owner'}));
} }
if ($forced->{'qacontact'}) { if ($forced->{'qacontact'}) {
push (@qa_contacts, login_to_id($forced->{'qacontact'}, THROW_ERROR)); push (@qa_contacts, Bugzilla::User->check($forced->{'qacontact'}));
} }
if ($forced->{'cc'}) { if ($forced->{'cc'}) {
foreach my $cc (@{$forced->{'cc'}}) { foreach my $cc (@{$forced->{'cc'}}) {
push(@ccs, login_to_id($cc, THROW_ERROR)); push(@ccs, Bugzilla::User->check($cc));
}
}
# Convert to names, for later display
$values{'changer'} = $changer;
# If no changer is specified, then it has no name.
if ($changer) {
$values{'changername'} = Bugzilla::User->new({name => $changer})->name;
} }
$values{'assigned_to'} = user_id_to_login($values{'assigned_to'});
$values{'reporter'} = user_id_to_login($values{'reporter'});
if ($values{'qa_contact'}) {
$values{'qa_contact'} = user_id_to_login($values{'qa_contact'});
} }
$values{'cc'} = join(', ', @cc_login_names);
$values{'estimated_time'} = format_time_decimal($values{'estimated_time'});
if ($values{'deadline'}) {
$values{'deadline'} = time2str("%Y-%m-%d", str2time($values{'deadline'}));
}
my $dependslist = $dbh->selectcol_arrayref(
'SELECT dependson FROM dependencies
WHERE blocked = ? ORDER BY dependson',
undef, ($id));
$values{'dependson'} = join(",", @$dependslist); my @args = ($bug->id);
my $blockedlist = $dbh->selectcol_arrayref(
'SELECT blocked FROM dependencies
WHERE dependson = ? ORDER BY blocked',
undef, ($id));
$values{'blocked'} = join(",", @$blockedlist);
my $grouplist = $dbh->selectcol_arrayref(
' SELECT name FROM groups
INNER JOIN bug_group_map
ON groups.id = bug_group_map.group_id
AND bug_group_map.bug_id = ?',
undef, ($id));
$values{'bug_group'} = join(', ', @$grouplist);
my @args = ($id);
# If lastdiffed is NULL, then we don't limit the search on time. # If lastdiffed is NULL, then we don't limit the search on time.
my $when_restriction = ''; my $when_restriction = '';
...@@ -291,7 +213,6 @@ sub Send { ...@@ -291,7 +213,6 @@ sub Send {
push(@diffparts, $diffpart); push(@diffparts, $diffpart);
push(@changedfields, $what); push(@changedfields, $what);
} }
$values{'changed_fields'} = join(' ', @changedfields);
my @depbugs; my @depbugs;
my $deptext = ""; my $deptext = "";
...@@ -307,7 +228,8 @@ sub Send { ...@@ -307,7 +228,8 @@ sub Send {
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 fielddefs.description, bugs_activity.removed,
bugs_activity.added
FROM bugs_activity FROM bugs_activity
INNER JOIN bugs INNER JOIN bugs
ON bugs.bug_id = bugs_activity.bug_id ON bugs.bug_id = bugs_activity.bug_id
...@@ -326,7 +248,7 @@ sub Send { ...@@ -326,7 +248,7 @@ sub Send {
my $lastbug = ""; my $lastbug = "";
my $interestingchange = 0; my $interestingchange = 0;
foreach my $dependency_diff (@$dependency_diffs) { foreach my $dependency_diff (@$dependency_diffs) {
my ($depbug, $summary, $what, $old, $new) = @$dependency_diff; my ($depbug, $summary, $fieldname, $what, $old, $new) = @$dependency_diff;
if ($depbug ne $lastbug) { if ($depbug ne $lastbug) {
if ($interestingchange) { if ($interestingchange) {
...@@ -341,8 +263,8 @@ sub Send { ...@@ -341,8 +263,8 @@ sub Send {
$thisdiff .= ('-' x 76) . "\n"; $thisdiff .= ('-' x 76) . "\n";
$interestingchange = 0; $interestingchange = 0;
} }
$thisdiff .= three_columns($fielddescription{$what}, $old, $new); $thisdiff .= three_columns($what, $old, $new);
if ($what eq 'bug_status' if ($fieldname eq 'bug_status'
&& is_open_state($old) ne is_open_state($new)) && is_open_state($old) ne is_open_state($new))
{ {
$interestingchange = 1; $interestingchange = 1;
...@@ -377,21 +299,21 @@ sub Send { ...@@ -377,21 +299,21 @@ sub Send {
# array of role constants. # array of role constants.
# CCs # CCs
$recipients{$_}->{+REL_CC} = BIT_DIRECT foreach (@ccs); $recipients{$_->id}->{+REL_CC} = BIT_DIRECT foreach (@ccs);
# Reporter (there's only ever one) # Reporter (there's only ever one)
$recipients{$reporter}->{+REL_REPORTER} = BIT_DIRECT; $recipients{$bug->reporter->id}->{+REL_REPORTER} = BIT_DIRECT;
# QA Contact # QA Contact
if (Bugzilla->params->{'useqacontact'}) { if (Bugzilla->params->{'useqacontact'}) {
foreach (@qa_contacts) { foreach (@qa_contacts) {
# QA Contact can be blank; ignore it if so. # QA Contact can be blank; ignore it if so.
$recipients{$_}->{+REL_QA} = BIT_DIRECT if $_; $recipients{$_->id}->{+REL_QA} = BIT_DIRECT if $_;
} }
} }
# Assignee # Assignee
$recipients{$_}->{+REL_ASSIGNEE} = BIT_DIRECT foreach (@assignees); $recipients{$_->id}->{+REL_ASSIGNEE} = BIT_DIRECT foreach (@assignees);
# The last relevant set of people are those who are being removed from # The last relevant set of people are those who are being removed from
# their roles in this change. We get their names out of the diffs. # their roles in this change. We get their names out of the diffs.
...@@ -497,18 +419,19 @@ sub Send { ...@@ -497,18 +419,19 @@ sub Send {
# dep checks passed. # dep checks passed.
if ($user->email_enabled && $dep_ok) { if ($user->email_enabled && $dep_ok) {
# OK, OK, if we must. Email the user. # OK, OK, if we must. Email the user.
$sent_mail = sendMail($user, $sent_mail = sendMail(
\@headerlist, { to => $user,
\%rels_which_want, fields => \@fields,
\%values, bug => $bug,
\%defmailhead, comments => $comments,
\%fielddescription, is_new => !$start,
\@diffparts, changer => $changer,
$comments, watchers => exists $watching{$user_id} ?
! $start, $watching{$user_id} : undef,
$id, diff_parts => \@diffparts,
exists $watching{$user_id} ? rels_which_want => \%rels_which_want,
$watching{$user_id} : undef); changed_fields => \@changedfields,
});
} }
} }
...@@ -522,20 +445,24 @@ sub Send { ...@@ -522,20 +445,24 @@ sub Send {
$dbh->do('UPDATE bugs SET lastdiffed = ? WHERE bug_id = ?', $dbh->do('UPDATE bugs SET lastdiffed = ? WHERE bug_id = ?',
undef, ($end, $id)); undef, ($end, $id));
$bug->{lastdiffed} = $end;
return {'sent' => \@sent, 'excluded' => \@excluded}; return {'sent' => \@sent, 'excluded' => \@excluded};
} }
sub sendMail { sub sendMail {
my ($user, $hlRef, $relRef, $valueRef, $dmhRef, $fdRef, my $params = shift;
$diffRef, $comments_in, $isnew, $id, $watchingRef) = @_;
my $user = $params->{to};
my @send_comments = @$comments_in; my @fields = @{ $params->{fields} };
my %values = %$valueRef; my $bug = $params->{bug};
my @headerlist = @$hlRef; my @send_comments = @{ $params->{comments} };
my %mailhead = %$dmhRef; my $isnew = $params->{is_new};
my %fielddescription = %$fdRef; my $changer = $params->{changer};
my @diffparts = @$diffRef; my $watchingRef = $params->{watchers};
my @diffparts = @{ $params->{diff_parts} };
my $relRef = $params->{rels_which_want};
my @changed_fields = @{ $params->{changed_fields} };
# Build difftext (the actions) by verifying the user should see them # Build difftext (the actions) by verifying the user should see them
my $difftext = ""; my $difftext = "";
...@@ -584,14 +511,31 @@ sub sendMail { ...@@ -584,14 +511,31 @@ sub sendMail {
$diffs =~ s/^\n+//s; $diffs =~ s/\n+$//s; $diffs =~ s/^\n+//s; $diffs =~ s/\n+$//s;
if ($isnew) { if ($isnew) {
my $head = ""; my $head = "";
foreach my $f (@headerlist) { foreach my $field (@fields) {
next unless $mailhead{$f}; my $name = $field->name;
my $value = $values{$f}; my $value = $bug->$name;
if (ref $value eq 'ARRAY') {
$value = join(', ', @$value);
}
elsif (ref $value && $value->isa('Bugzilla::User')) {
$value = $value->login;
}
elsif (ref $value && $value->isa('Bugzilla::Object')) {
$value = $value->name;
}
elsif ($name eq 'estimated_time') {
$value = format_time_decimal($value);
}
elsif ($name eq 'deadline') {
$value = time2str("%Y-%m-%d", str2time($value));
}
# If there isn't anything to show, don't include this header. # If there isn't anything to show, don't include this header.
next unless $value; next unless $value;
# Only send estimated_time if it is enabled and the user is in the group. # Only send estimated_time if it is enabled and the user is in the group.
if (($f ne 'estimated_time' && $f ne 'deadline') || $user->is_timetracker) { if (($name ne 'estimated_time' && $name ne 'deadline') || $user->is_timetracker) {
my $desc = $fielddescription{$f}; my $desc = $field->description;
$head .= multiline_sprintf(FORMAT_DOUBLE, ["$desc:", $value], $head .= multiline_sprintf(FORMAT_DOUBLE, ["$desc:", $value],
FORMAT_2_SIZE); FORMAT_2_SIZE);
} }
...@@ -615,31 +559,16 @@ sub sendMail { ...@@ -615,31 +559,16 @@ sub sendMail {
my $vars = { my $vars = {
isnew => $isnew, isnew => $isnew,
to_user => $user, to_user => $user,
bugid => $id, bug => $bug,
alias => Bugzilla->params->{'usebugaliases'} ? $values{'alias'} : "", changedfields => @changed_fields,
classification => $values{'classification'},
product => $values{'product'},
comp => $values{'component'},
keywords => $values{'keywords'},
severity => $values{'bug_severity'},
status => $values{'bug_status'},
priority => $values{'priority'},
assignedto => $values{'assigned_to'},
assignedtoname => Bugzilla::User->new({name => $values{'assigned_to'}})->name,
targetmilestone => $values{'target_milestone'},
changedfields => $values{'changed_fields'},
summary => $values{'short_desc'},
reasons => \@reasons, reasons => \@reasons,
reasons_watch => \@reasons_watch, reasons_watch => \@reasons_watch,
reasonsheader => join(" ", @headerrel), reasonsheader => join(" ", @headerrel),
reasonswatchheader => join(" ", @watchingrel), reasonswatchheader => join(" ", @watchingrel),
changer => $values{'changer'}, changer => $changer,
changername => $values{'changername'},
reporter => $values{'reporter'},
reportername => Bugzilla::User->new({name => $values{'reporter'}})->name,
diffs => $diffs, diffs => $diffs,
new_comments => \@send_comments, new_comments => \@send_comments,
threadingmarker => build_thread_marker($id, $user->id, $isnew), threadingmarker => build_thread_marker($bug->id, $user->id, $isnew),
}; };
my $msg; my $msg;
......
...@@ -1427,7 +1427,7 @@ sub wants_bug_mail { ...@@ -1427,7 +1427,7 @@ sub wants_bug_mail {
# #
# We do them separately because if _any_ of them are set, we don't want # We do them separately because if _any_ of them are set, we don't want
# the mail. # the mail.
if ($wants_mail && $changer && ($self->login eq $changer)) { if ($wants_mail && $changer && ($self->id == $changer->id)) {
$wants_mail &= $self->wants_mail([EVT_CHANGED_BY_ME], $relationship); $wants_mail &= $self->wants_mail([EVT_CHANGED_BY_ME], $relationship);
} }
......
...@@ -430,7 +430,7 @@ sub create { ...@@ -430,7 +430,7 @@ sub create {
Bugzilla->login(LOGIN_REQUIRED); Bugzilla->login(LOGIN_REQUIRED);
$params = Bugzilla::Bug::map_fields($params); $params = Bugzilla::Bug::map_fields($params);
my $bug = Bugzilla::Bug->create($params); my $bug = Bugzilla::Bug->create($params);
Bugzilla::BugMail::Send($bug->bug_id, { changer => $bug->reporter->login }); Bugzilla::BugMail::Send($bug->bug_id, { changer => $bug->reporter });
return { id => $self->type('int', $bug->bug_id) }; return { id => $self->type('int', $bug->bug_id) };
} }
...@@ -520,7 +520,7 @@ sub add_comment { ...@@ -520,7 +520,7 @@ sub add_comment {
$dbh->bz_commit_transaction(); $dbh->bz_commit_transaction();
# Send mail. # Send mail.
Bugzilla::BugMail::Send($bug->bug_id, { changer => Bugzilla->user->login }); Bugzilla::BugMail::Send($bug->bug_id, { changer => Bugzilla->user });
return { id => $self->type('int', $new_comment_id) }; return { id => $self->type('int', $new_comment_id) };
} }
...@@ -566,7 +566,7 @@ sub update_see_also { ...@@ -566,7 +566,7 @@ sub update_see_also {
$changes{$bug->id}->{see_also} = { added => [], removed => [] }; $changes{$bug->id}->{see_also} = { added => [], removed => [] };
} }
Bugzilla::BugMail::Send($bug->id, { changer => $user->login }); Bugzilla::BugMail::Send($bug->id, { changer => $user });
} }
return { changes => \%changes }; return { changes => \%changes };
......
...@@ -538,7 +538,7 @@ sub insert { ...@@ -538,7 +538,7 @@ sub insert {
$vars->{'header_done'} = 1; $vars->{'header_done'} = 1;
$vars->{'contenttypemethod'} = $cgi->param('contenttypemethod'); $vars->{'contenttypemethod'} = $cgi->param('contenttypemethod');
my $recipients = { 'changer' => $user->login, 'owner' => $owner }; my $recipients = { 'changer' => $user, 'owner' => $owner };
$vars->{'sent_bugmail'} = Bugzilla::BugMail::Send($bugid, $recipients); $vars->{'sent_bugmail'} = Bugzilla::BugMail::Send($bugid, $recipients);
print $cgi->header(); print $cgi->header();
...@@ -666,7 +666,7 @@ sub update { ...@@ -666,7 +666,7 @@ sub update {
$vars->{'bugs'} = [$bug]; $vars->{'bugs'} = [$bug];
$vars->{'header_done'} = 1; $vars->{'header_done'} = 1;
$vars->{'sent_bugmail'} = $vars->{'sent_bugmail'} =
Bugzilla::BugMail::Send($bug->id, { 'changer' => $user->login }); Bugzilla::BugMail::Send($bug->id, { 'changer' => $user });
print $cgi->header(); print $cgi->header();
...@@ -739,7 +739,7 @@ sub delete_attachment { ...@@ -739,7 +739,7 @@ sub delete_attachment {
$vars->{'header_done'} = 1; $vars->{'header_done'} = 1;
$vars->{'sent_bugmail'} = $vars->{'sent_bugmail'} =
Bugzilla::BugMail::Send($bug->id, { 'changer' => $user->login }); Bugzilla::BugMail::Send($bug->id, { 'changer' => $user });
$template->process("attachment/updated.html.tmpl", $vars) $template->process("attachment/updated.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -56,13 +56,14 @@ if ($changer !~ /$match/) { ...@@ -56,13 +56,14 @@ if ($changer !~ /$match/) {
print STDERR "Changer \"$changer\" doesn't match email regular expression.\n"; print STDERR "Changer \"$changer\" doesn't match email regular expression.\n";
usage(); usage();
} }
if(!login_to_id($changer)) { my $changer_user = new Bugzilla::User({ name => $changer });
print STDERR "\"$changer\" is not a login ID.\n"; unless ($changer_user) {
print STDERR "\"$changer\" is not a valid user.\n";
usage(); usage();
} }
# Send the email. # Send the email.
my $outputref = Bugzilla::BugMail::Send($bugnum, {'changer' => $changer }); my $outputref = Bugzilla::BugMail::Send($bugnum, {'changer' => $changer_user });
# Report the results. # Report the results.
my $sent = scalar(@{$outputref->{sent}}); my $sent = scalar(@{$outputref->{sent}});
......
...@@ -647,7 +647,7 @@ if ($action eq 'search') { ...@@ -647,7 +647,7 @@ if ($action eq 'search') {
# Send mail about what we've done to bugs. # Send mail about what we've done to bugs.
# The deleted user is not notified of the changes. # The deleted user is not notified of the changes.
foreach (keys(%updatedbugs)) { foreach (keys(%updatedbugs)) {
Bugzilla::BugMail::Send($_, {'changer' => $user->login} ); Bugzilla::BugMail::Send($_, {'changer' => $user} );
} }
########################################################################### ###########################################################################
......
...@@ -422,7 +422,7 @@ handle_attachments($bug, $attachments, $comment); ...@@ -422,7 +422,7 @@ handle_attachments($bug, $attachments, $comment);
# to wait for $bug->update() to be fully used in email_in.pl first. So # to wait for $bug->update() to be fully used in email_in.pl first. So
# currently, process_bug.cgi does the mail sending for bugs, and this does # currently, process_bug.cgi does the mail sending for bugs, and this does
# any mail sending for attachments after the first one. # any mail sending for attachments after the first one.
Bugzilla::BugMail::Send($bug->id, { changer => Bugzilla->user->login }); Bugzilla::BugMail::Send($bug->id, { changer => Bugzilla->user });
debug_print("Sent bugmail"); debug_print("Sent bugmail");
......
...@@ -619,7 +619,7 @@ sub _update_votes { ...@@ -619,7 +619,7 @@ sub _update_votes {
foreach my $bug_id (@updated_bugs) { foreach my $bug_id (@updated_bugs) {
$vars->{'id'} = $bug_id; $vars->{'id'} = $bug_id;
$vars->{'sent_bugmail'} = $vars->{'sent_bugmail'} =
Bugzilla::BugMail::Send($bug_id, { 'changer' => $user->login }); Bugzilla::BugMail::Send($bug_id, { 'changer' => $user });
$template->process("bug/process/results.html.tmpl", $vars) $template->process("bug/process/results.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -729,7 +729,7 @@ sub _modify_bug_votes { ...@@ -729,7 +729,7 @@ sub _modify_bug_votes {
# And send out emails about changed bugs # And send out emails about changed bugs
foreach my $bug_id (@updated_bugs) { foreach my $bug_id (@updated_bugs) {
my $sent_bugmail = Bugzilla::BugMail::Send( my $sent_bugmail = Bugzilla::BugMail::Send(
$bug_id, { changer => Bugzilla->user->login }); $bug_id, { changer => Bugzilla->user });
$changes->{'confirmed_bugs_sent_bugmail'}->{$bug_id} = $sent_bugmail; $changes->{'confirmed_bugs_sent_bugmail'}->{$bug_id} = $sent_bugmail;
} }
} }
......
...@@ -1285,7 +1285,7 @@ sub process_bug { ...@@ -1285,7 +1285,7 @@ sub process_bug {
} }
Debug( $log, OK_LEVEL ); Debug( $log, OK_LEVEL );
push(@logs, $log); push(@logs, $log);
Bugzilla::BugMail::Send( $id, { 'changer' => $exporter_login } ) if ($mail); Bugzilla::BugMail::Send( $id, { 'changer' => $exporter } ) if ($mail);
# done with the xml data. Lets clear it from memory # done with the xml data. Lets clear it from memory
$twig->purge; $twig->purge;
......
...@@ -245,7 +245,7 @@ if ($token) { ...@@ -245,7 +245,7 @@ if ($token) {
("createbug:$id", $token)); ("createbug:$id", $token));
} }
my $recipients = { changer => $user->login }; my $recipients = { changer => $user };
my $bug_sent = Bugzilla::BugMail::Send($id, $recipients); my $bug_sent = Bugzilla::BugMail::Send($id, $recipients);
$bug_sent->{type} = 'created'; $bug_sent->{type} = 'created';
$bug_sent->{id} = $id; $bug_sent->{id} = $id;
......
...@@ -469,7 +469,7 @@ if ($move_action eq Bugzilla->params->{'move-button-text'}) { ...@@ -469,7 +469,7 @@ if ($move_action eq Bugzilla->params->{'move-button-text'}) {
# Now send emails. # Now send emails.
foreach my $bug (@bug_objects) { foreach my $bug (@bug_objects) {
$vars->{'mailrecipients'} = { 'changer' => $user->login }; $vars->{'mailrecipients'} = { 'changer' => $user };
$vars->{'id'} = $bug->id; $vars->{'id'} = $bug->id;
$vars->{'type'} = "move"; $vars->{'type'} = "move";
send_results($bug->id, $vars); send_results($bug->id, $vars);
...@@ -589,7 +589,7 @@ foreach my $bug (@bug_objects) { ...@@ -589,7 +589,7 @@ foreach my $bug (@bug_objects) {
cc => [split(/[\s,]+/, $old_cc)], cc => [split(/[\s,]+/, $old_cc)],
owner => $old_own, owner => $old_own,
qacontact => $old_qa, qacontact => $old_qa,
changer => Bugzilla->user->login }; changer => Bugzilla->user };
$vars->{'id'} = $bug->id; $vars->{'id'} = $bug->id;
$vars->{'type'} = "bug"; $vars->{'type'} = "bug";
...@@ -602,7 +602,7 @@ foreach my $bug (@bug_objects) { ...@@ -602,7 +602,7 @@ foreach my $bug (@bug_objects) {
# other bug of any changes to that bug. # other bug of any changes to that bug.
my $new_dup_id = $changes->{'dup_id'} ? $changes->{'dup_id'}->[1] : undef; my $new_dup_id = $changes->{'dup_id'} ? $changes->{'dup_id'}->[1] : undef;
if ($new_dup_id) { if ($new_dup_id) {
$vars->{'mailrecipients'} = { 'changer' => Bugzilla->user->login }; $vars->{'mailrecipients'} = { 'changer' => Bugzilla->user };
$vars->{'id'} = $new_dup_id; $vars->{'id'} = $new_dup_id;
$vars->{'type'} = "dupe"; $vars->{'type'} = "dupe";
...@@ -614,7 +614,7 @@ foreach my $bug (@bug_objects) { ...@@ -614,7 +614,7 @@ foreach my $bug (@bug_objects) {
my %all_dep_changes = (%notify_deps, %changed_deps); my %all_dep_changes = (%notify_deps, %changed_deps);
foreach my $id (sort { $a <=> $b } (keys %all_dep_changes)) { foreach my $id (sort { $a <=> $b } (keys %all_dep_changes)) {
$vars->{'mailrecipients'} = { 'changer' => Bugzilla->user->login }; $vars->{'mailrecipients'} = { 'changer' => Bugzilla->user };
$vars->{'id'} = $id; $vars->{'id'} = $id;
$vars->{'type'} = "dep"; $vars->{'type'} = "dep";
......
...@@ -248,7 +248,7 @@ if ($cgi->param('rescanallBugMail')) { ...@@ -248,7 +248,7 @@ if ($cgi->param('rescanallBugMail')) {
# and so choosing this user as being the last one having done a change # and so choosing this user as being the last one having done a change
# for the bug may be problematic. So the best we can do at this point # for the bug may be problematic. So the best we can do at this point
# is to choose the currently logged in user for email notification. # is to choose the currently logged in user for email notification.
$vars->{'changer'} = Bugzilla->user->login; $vars->{'changer'} = Bugzilla->user;
foreach my $bugid (@$list) { foreach my $bugid (@$list) {
Bugzilla::BugMail::Send($bugid, $vars); Bugzilla::BugMail::Send($bugid, $vars);
......
...@@ -23,26 +23,26 @@ ...@@ -23,26 +23,26 @@
From: [% Param('mailfrom') %] From: [% Param('mailfrom') %]
To: [% to_user.email %] To: [% to_user.email %]
Subject: [[% terms.Bug %] [%+ bugid %]] [% 'New: ' IF isnew %][%+ summary %] Subject: [[% terms.Bug %] [%+ bug.id %]] [% 'New: ' IF isnew %][%+ bug.short_desc %]
X-Bugzilla-Reason: [% reasonsheader %] X-Bugzilla-Reason: [% reasonsheader %]
X-Bugzilla-Type: [% isnew ? 'new' : 'changed' %] X-Bugzilla-Type: [% isnew ? 'new' : 'changed' %]
X-Bugzilla-Watch-Reason: [% reasonswatchheader %] X-Bugzilla-Watch-Reason: [% reasonswatchheader %]
[% IF Param('useclassification') %] [% IF Param('useclassification') %]
X-Bugzilla-Classification: [% classification %] X-Bugzilla-Classification: [% bug.classification %]
[% END %] [% END %]
X-Bugzilla-Product: [% product %] X-Bugzilla-Product: [% bug.product %]
X-Bugzilla-Component: [% comp %] X-Bugzilla-Component: [% bug.component %]
X-Bugzilla-Keywords: [% keywords %] X-Bugzilla-Keywords: [% bug.keywords %]
X-Bugzilla-Severity: [% severity %] X-Bugzilla-Severity: [% bug.bug_severity %]
X-Bugzilla-Who: [% changer %] X-Bugzilla-Who: [% changer.login %]
X-Bugzilla-Status: [% status %] X-Bugzilla-Status: [% bug.bug_status %]
X-Bugzilla-Priority: [% priority %] X-Bugzilla-Priority: [% bug.priority %]
X-Bugzilla-Assigned-To: [% assignedto %] X-Bugzilla-Assigned-To: [% bug.assigned_to.login %]
X-Bugzilla-Target-Milestone: [% targetmilestone %] X-Bugzilla-Target-Milestone: [% bug.target_milestone %]
X-Bugzilla-Changed-Fields: [% changedfields %] X-Bugzilla-Changed-Fields: [% changedfields %]
[%+ threadingmarker %] [%+ threadingmarker %]
[%+ urlbase %]show_bug.cgi?id=[% bugid %] [%+ urlbase %]show_bug.cgi?id=[% bug.id %]
[%- IF diffs %] [%- IF diffs %]
[%+ diffs %] [%+ diffs %]
......
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