summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2016-12-15 00:49:48 +0100
committerDylan William Hardison <dylan@hardison.net>2016-12-15 00:50:08 +0100
commit490499f9a35b36b72c0b7b30322b9838774b93fe (patch)
tree541fe6f0b4c74e5ac320698e2ef372ffa948b9ec /Bugzilla
parent9f141e825ed983fd2540bbfadb4be693ddce16a5 (diff)
downloadbugzilla-490499f9a35b36b72c0b7b30322b9838774b93fe.tar.gz
bugzilla-490499f9a35b36b72c0b7b30322b9838774b93fe.tar.xz
Bug 1313766 - Bugzilla::Bug->send_changes() should not output HTML directly
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm52
-rw-r--r--Bugzilla/Error/Template.pm26
2 files changed, 48 insertions, 30 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 69734e6c0..637d94114 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1331,13 +1331,13 @@ sub remove_from_db {
#####################################################################
sub send_changes {
- my ($self, $changes, $vars) = @_;
-
+ my ($self, $changes) = @_;
+ my @results;
my $user = Bugzilla->user;
- my $old_qa = $changes->{'qa_contact'}
+ my $old_qa = $changes->{'qa_contact'}
? $changes->{'qa_contact'}->[0] : '';
- my $old_own = $changes->{'assigned_to'}
+ my $old_own = $changes->{'assigned_to'}
? $changes->{'assigned_to'}->[0] : '';
my $old_cc = $changes->{cc}
? $changes->{cc}->[0] : '';
@@ -1349,15 +1349,15 @@ sub send_changes {
changer => $user,
);
- my $recipient_count = _send_bugmail(
- { id => $self->id, type => 'bug', forced => \%forced }, $vars);
+ push @results, _send_bugmail(
+ { id => $self->id, type => 'bug', forced => \%forced });
# If the bug was marked as a duplicate, we need to notify users on the
# other bug of any changes to that bug.
my $new_dup_id = $changes->{'dup_id'} ? $changes->{'dup_id'}->[1] : undef;
if ($new_dup_id) {
- $recipient_count += _send_bugmail(
- { forced => { changer => $user }, type => "dupe", id => $new_dup_id }, $vars);
+ push @results, _send_bugmail(
+ { forced => { changer => $user }, type => "dupe", id => $new_dup_id });
}
# If there were changes in dependencies, we need to notify those
@@ -1376,7 +1376,7 @@ sub send_changes {
foreach my $id (@{ $self->blocked }) {
$params->{id} = $id;
- $recipient_count += _send_bugmail($params, $vars);
+ push @results, _send_bugmail($params);
}
}
}
@@ -1394,37 +1394,28 @@ sub send_changes {
delete $changed_deps{''};
foreach my $id (sort { $a <=> $b } (keys %changed_deps)) {
- $recipient_count += _send_bugmail(
- { forced => { changer => $user }, type => "dep", id => $id }, $vars);
+ push @results, _send_bugmail(
+ { forced => { changer => $user }, type => "dep", id => $id });
}
# Sending emails for the referenced bugs.
foreach my $ref_bug_id (uniq @{ $self->{see_also_changes} || [] }) {
- $recipient_count += _send_bugmail(
- { forced => { changer => $user }, id => $ref_bug_id }, $vars);
+ push @results, _send_bugmail(
+ { forced => { changer => $user }, id => $ref_bug_id });
}
- return $recipient_count;
+ return \@results;
}
sub _send_bugmail {
- my ($params, $vars) = @_;
+ my ($params) = @_;
require Bugzilla::BugMail;
- my $results =
+ my $sent_bugmail =
Bugzilla::BugMail::Send($params->{'id'}, $params->{'forced'}, $params);
- if (Bugzilla->usage_mode == USAGE_MODE_BROWSER) {
- my $template = Bugzilla->template;
- $vars->{$_} = $params->{$_} foreach keys %$params;
- $vars->{'sent_bugmail'} = $results;
- $template->process("bug/process/results.html.tmpl", $vars)
- || ThrowTemplateError($template->error());
- $vars->{'header_done'} = 1;
- }
-
- return scalar @{ $results->{sent} };
+ return { params => $params, sent_bugmail => $sent_bugmail };
}
#####################################################################
@@ -2778,10 +2769,11 @@ sub _set_product {
if (%vars) {
$vars{product} = $product;
$vars{bug} = $self;
- my $template = Bugzilla->template;
- $template->process("bug/process/verify-new-product.html.tmpl",
- \%vars) || ThrowTemplateError($template->error());
- exit;
+ require Bugzilla::Error::Template;
+ die Bugzilla::Error::Template->new(
+ file => "bug/process/verify-new-product.html.tmpl",
+ vars => \%vars
+ );
}
}
else {
diff --git a/Bugzilla/Error/Template.pm b/Bugzilla/Error/Template.pm
new file mode 100644
index 000000000..a3afa7e4d
--- /dev/null
+++ b/Bugzilla/Error/Template.pm
@@ -0,0 +1,26 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Error::Template;
+
+use 5.10.1;
+use strict;
+use warnings;
+use Moo;
+
+has 'file' => (
+ is => 'ro',
+ required => 1,
+);
+
+has 'vars' => (
+ is => 'ro',
+ default => sub { {} },
+);
+
+
+1; \ No newline at end of file