From 9a8e6dd21f64b0242939c2abf789e274995b4ded Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 12 Mar 2018 17:02:09 -0400 Subject: Bug 1437238 - Create override parameters for mailer configuration --- Bugzilla/BugMail.pm | 2 +- Bugzilla/Install/Localconfig.pm | 14 +++++++------- Bugzilla/Mailer.pm | 8 ++++---- Bugzilla/Send/Sendmail.pm | 2 +- README.rst | 9 +++++++++ template/en/default/admin/admin.html.tmpl | 2 +- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index defe7c84f..915405a0e 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -421,7 +421,7 @@ sub sendMail { bugmailtype => $bugmailtype, }; - if (Bugzilla->params->{'use_mailer_queue'}) { + if (Bugzilla->get_param_with_override('use_mailer_queue')) { enqueue($vars); } else { MessageToMTA(_generate_bugmail($vars)); diff --git a/Bugzilla/Install/Localconfig.pm b/Bugzilla/Install/Localconfig.pm index ba8e8dc57..de2219f16 100644 --- a/Bugzilla/Install/Localconfig.pm +++ b/Bugzilla/Install/Localconfig.pm @@ -43,7 +43,7 @@ our @EXPORT_OK = qw( # might want to change this for upstream use constant ENV_PREFIX => 'BMO_'; -use constant PARAM_OVERRIDE => qw( shadowdb shadowdbhost shadowdbport shadowdbsock ); +use constant PARAM_OVERRIDE => qw( use_mailer_queue mail_delivery_method shadowdb shadowdbhost shadowdbport shadowdbsock ); sub _sensible_group { return '' if ON_WINDOWS; @@ -135,12 +135,12 @@ use constant LOCALCONFIG_VARS => ( { name => 'param_override', default => { - memcached_servers => undef, - memcached_namespace => undef, - shadowdb => undef, - shadowdbhost => undef, - shadowdbport => undef, - shadowdbsock => undef, + use_mailer_queue => undef, + mail_delivery_method => undef, + shadowdb => undef, + shadowdbhost => undef, + shadowdbport => undef, + shadowdbsock => undef, }, }, { diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm index 6e46d1862..e245a05e0 100644 --- a/Bugzilla/Mailer.pm +++ b/Bugzilla/Mailer.pm @@ -37,10 +37,10 @@ use Bugzilla::Version qw(vers_cmp); sub MessageToMTA { my ($msg, $send_now) = (@_); - my $method = Bugzilla->params->{'mail_delivery_method'}; + my $method = Bugzilla->get_param_with_override('mail_delivery_method'); return if $method eq 'None'; - if (Bugzilla->params->{'use_mailer_queue'} and !$send_now) { + if (Bugzilla->get_param_with_override('use_mailer_queue') and !$send_now) { Bugzilla->job_queue->insert('send_mail', { msg => $msg }); return; } @@ -66,7 +66,7 @@ sub MessageToMTA { } # Ensure that we are not sending emails too quickly to recipients. - if (Bugzilla->params->{use_mailer_queue} + if (Bugzilla->get_param_with_override('use_mailer_queue') && (EMAIL_LIMIT_PER_MINUTE || EMAIL_LIMIT_PER_HOUR)) { $dbh->do( @@ -226,7 +226,7 @@ sub MessageToMTA { } # insert into email_rates - if (Bugzilla->params->{use_mailer_queue} + if (Bugzilla->get_param_with_override('use_mailer_queue') && (EMAIL_LIMIT_PER_MINUTE || EMAIL_LIMIT_PER_HOUR)) { $dbh->do( diff --git a/Bugzilla/Send/Sendmail.pm b/Bugzilla/Send/Sendmail.pm index 71c1f67ce..81c2190e5 100644 --- a/Bugzilla/Send/Sendmail.pm +++ b/Bugzilla/Send/Sendmail.pm @@ -37,7 +37,7 @@ sub send { unless (close $pipe) { return failure "error when closing pipe to $mailer: $!" if $!; my ($error_message, $is_transient) = _map_exitcode($? >> 8); - if (Bugzilla->params->{'use_mailer_queue'}) { + if (Bugzilla->get_param_with_override('use_mailer_queue')) { # Return success for errors which are fatal so Bugzilla knows to # remove them from the queue if ($is_transient) { diff --git a/README.rst b/README.rst index a2b23d069..1576f07b7 100644 --- a/README.rst +++ b/README.rst @@ -297,6 +297,15 @@ BMO_apache_size_limit This is the max amount of unshared memory (in kb) that the apache process is allowed to use before Apache::SizeLimit kills it. +BMO_mail_delivery_method + Usually configured on the MTA section of admin interface, but may be set here for testing purposes. + Valid values are None, Test, Sendmail, or SMTP. + If set to Test, email will be appended to the /app/data/mailer.test file. + +BMO_use_mailer_queue + Usually configured on the MTA section of the admin interface, you may change this here for testing purposes. + Should be 1 or 0. If 1, the job queue will be used. For testing, only set to 0 if the BMO_mail_delivery_method is None or Test. + HTTPD_StartServers Sets the number of child server processes created on startup. As the number of processes is dynamically controlled depending on the load, diff --git a/template/en/default/admin/admin.html.tmpl b/template/en/default/admin/admin.html.tmpl index 86bd8b973..62a246ceb 100644 --- a/template/en/default/admin/admin.html.tmpl +++ b/template/en/default/admin/admin.html.tmpl @@ -127,7 +127,7 @@ and time, and get the result of these queries directly per email. This is a good way to create reminders and to keep track of the activity in your installation. - [% IF Param('use_mailer_queue') %] + [% IF Bugzilla.localconfig.param_override.use_mailer_queue OR Param('use_mailer_queue') %] [% class = user.in_group('admin') ? "" : "forbidden" %]
Job Queue
View the queue of undelivered/deferred jobs/emails.
-- cgit v1.2.3-24-g4f1b