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 {
delta_ts
estimated_time
everconfirmed
lastdiffed
op_sys
priority
product_id
......@@ -2612,6 +2613,11 @@ sub blocked {
# Even bugs in an error state always have a bug_id.
sub bug_id { $_[0]->{'bug_id'}; }
sub bug_group {
my ($self) = @_;
return join(', ', (map { $_->name } @{$self->groups_in}));
}
sub related_bugs {
my ($self, $relationship) = @_;
return [] if $self->{'error'};
......@@ -3586,7 +3592,8 @@ sub _validate_attribute {
qw(error groups product_id component_id
comments milestoneurl attachments isopened
flag_types num_attachment_flag_types
show_attachment_flags any_flags_requesteeble),
show_attachment_flags any_flags_requesteeble
lastdiffed),
# Bug fields.
Bugzilla::Bug->fields
......
......@@ -1427,7 +1427,7 @@ sub wants_bug_mail {
#
# We do them separately because if _any_ of them are set, we don't want
# 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);
}
......
......@@ -430,7 +430,7 @@ sub create {
Bugzilla->login(LOGIN_REQUIRED);
$params = Bugzilla::Bug::map_fields($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) };
}
......@@ -520,7 +520,7 @@ sub add_comment {
$dbh->bz_commit_transaction();
# 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) };
}
......@@ -566,7 +566,7 @@ sub update_see_also {
$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 };
......
......@@ -538,7 +538,7 @@ sub insert {
$vars->{'header_done'} = 1;
$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);
print $cgi->header();
......@@ -666,7 +666,7 @@ sub update {
$vars->{'bugs'} = [$bug];
$vars->{'header_done'} = 1;
$vars->{'sent_bugmail'} =
Bugzilla::BugMail::Send($bug->id, { 'changer' => $user->login });
Bugzilla::BugMail::Send($bug->id, { 'changer' => $user });
print $cgi->header();
......@@ -739,7 +739,7 @@ sub delete_attachment {
$vars->{'header_done'} = 1;
$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)
|| ThrowTemplateError($template->error());
......
......@@ -56,13 +56,14 @@ if ($changer !~ /$match/) {
print STDERR "Changer \"$changer\" doesn't match email regular expression.\n";
usage();
}
if(!login_to_id($changer)) {
print STDERR "\"$changer\" is not a login ID.\n";
my $changer_user = new Bugzilla::User({ name => $changer });
unless ($changer_user) {
print STDERR "\"$changer\" is not a valid user.\n";
usage();
}
# Send the email.
my $outputref = Bugzilla::BugMail::Send($bugnum, {'changer' => $changer });
my $outputref = Bugzilla::BugMail::Send($bugnum, {'changer' => $changer_user });
# Report the results.
my $sent = scalar(@{$outputref->{sent}});
......
......@@ -647,7 +647,7 @@ if ($action eq 'search') {
# Send mail about what we've done to bugs.
# The deleted user is not notified of the changes.
foreach (keys(%updatedbugs)) {
Bugzilla::BugMail::Send($_, {'changer' => $user->login} );
Bugzilla::BugMail::Send($_, {'changer' => $user} );
}
###########################################################################
......
......@@ -422,7 +422,7 @@ handle_attachments($bug, $attachments, $comment);
# 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
# 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");
......
......@@ -619,7 +619,7 @@ sub _update_votes {
foreach my $bug_id (@updated_bugs) {
$vars->{'id'} = $bug_id;
$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)
|| ThrowTemplateError($template->error());
......@@ -729,7 +729,7 @@ sub _modify_bug_votes {
# And send out emails about changed bugs
foreach my $bug_id (@updated_bugs) {
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;
}
}
......
......@@ -1285,7 +1285,7 @@ sub process_bug {
}
Debug( $log, OK_LEVEL );
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
$twig->purge;
......
......@@ -245,7 +245,7 @@ if ($token) {
("createbug:$id", $token));
}
my $recipients = { changer => $user->login };
my $recipients = { changer => $user };
my $bug_sent = Bugzilla::BugMail::Send($id, $recipients);
$bug_sent->{type} = 'created';
$bug_sent->{id} = $id;
......
......@@ -469,7 +469,7 @@ if ($move_action eq Bugzilla->params->{'move-button-text'}) {
# Now send emails.
foreach my $bug (@bug_objects) {
$vars->{'mailrecipients'} = { 'changer' => $user->login };
$vars->{'mailrecipients'} = { 'changer' => $user };
$vars->{'id'} = $bug->id;
$vars->{'type'} = "move";
send_results($bug->id, $vars);
......@@ -589,7 +589,7 @@ foreach my $bug (@bug_objects) {
cc => [split(/[\s,]+/, $old_cc)],
owner => $old_own,
qacontact => $old_qa,
changer => Bugzilla->user->login };
changer => Bugzilla->user };
$vars->{'id'} = $bug->id;
$vars->{'type'} = "bug";
......@@ -602,7 +602,7 @@ foreach my $bug (@bug_objects) {
# other bug of any changes to that bug.
my $new_dup_id = $changes->{'dup_id'} ? $changes->{'dup_id'}->[1] : undef;
if ($new_dup_id) {
$vars->{'mailrecipients'} = { 'changer' => Bugzilla->user->login };
$vars->{'mailrecipients'} = { 'changer' => Bugzilla->user };
$vars->{'id'} = $new_dup_id;
$vars->{'type'} = "dupe";
......@@ -614,7 +614,7 @@ foreach my $bug (@bug_objects) {
my %all_dep_changes = (%notify_deps, %changed_deps);
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->{'type'} = "dep";
......
......@@ -248,7 +248,7 @@ if ($cgi->param('rescanallBugMail')) {
# 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
# is to choose the currently logged in user for email notification.
$vars->{'changer'} = Bugzilla->user->login;
$vars->{'changer'} = Bugzilla->user;
foreach my $bugid (@$list) {
Bugzilla::BugMail::Send($bugid, $vars);
......
......@@ -23,26 +23,26 @@
From: [% Param('mailfrom') %]
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-Type: [% isnew ? 'new' : 'changed' %]
X-Bugzilla-Watch-Reason: [% reasonswatchheader %]
[% IF Param('useclassification') %]
X-Bugzilla-Classification: [% classification %]
X-Bugzilla-Classification: [% bug.classification %]
[% END %]
X-Bugzilla-Product: [% product %]
X-Bugzilla-Component: [% comp %]
X-Bugzilla-Keywords: [% keywords %]
X-Bugzilla-Severity: [% severity %]
X-Bugzilla-Who: [% changer %]
X-Bugzilla-Status: [% status %]
X-Bugzilla-Priority: [% priority %]
X-Bugzilla-Assigned-To: [% assignedto %]
X-Bugzilla-Target-Milestone: [% targetmilestone %]
X-Bugzilla-Product: [% bug.product %]
X-Bugzilla-Component: [% bug.component %]
X-Bugzilla-Keywords: [% bug.keywords %]
X-Bugzilla-Severity: [% bug.bug_severity %]
X-Bugzilla-Who: [% changer.login %]
X-Bugzilla-Status: [% bug.bug_status %]
X-Bugzilla-Priority: [% bug.priority %]
X-Bugzilla-Assigned-To: [% bug.assigned_to.login %]
X-Bugzilla-Target-Milestone: [% bug.target_milestone %]
X-Bugzilla-Changed-Fields: [% changedfields %]
[%+ threadingmarker %]
[%+ urlbase %]show_bug.cgi?id=[% bugid %]
[%+ urlbase %]show_bug.cgi?id=[% bug.id %]
[%- IF 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