Bugzilla – Attachment 124829 Details for
Bug 28803
process_message_queue.pl dies if any messsages in the message queue contain an invalid to_address
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28803: (follow-up) Error details improvement
Bug-28803-follow-up-Error-details-improvement.patch (text/plain), 4.51 KB, created by
Martin Renvoize (ashimema)
on 2021-09-13 09:20:28 UTC
(
hide
)
Description:
Bug 28803: (follow-up) Error details improvement
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-09-13 09:20:28 UTC
Size:
4.51 KB
patch
obsolete
>From 2c7c3bb8d15c76a46550c2c1239ffc93a0006e64 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 13 Sep 2021 10:18:46 +0100 >Subject: [PATCH] Bug 28803: (follow-up) Error details improvement > >This patch updates the exceptions thrown by Koha::Email to include the >parameter that failed email validation and then updates the failure code >to include this parameter and finally display this field in the template. >--- > C4/Letters.pm | 24 +++++++++++++------ > Koha/Email.pm | 9 ++++--- > .../prog/en/modules/members/notices.tt | 2 +- > 3 files changed, 22 insertions(+), 13 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 118d5a4583..cee7e58e94 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1406,13 +1406,23 @@ sub _send_message_by_email { > ); > } > catch { >- _set_message_status( >- { >- message_id => $message->{'message_id'}, >- status => 'failed', >- failure_code => 'INVALID_EMAIL' >- } >- ); >+ if ( ref($_) eq 'Koha::Exceptions::BadParameter' ) { >+ _set_message_status( >+ { >+ message_id => $message->{'message_id'}, >+ status => 'failed', >+ failure_code => "INVALID_EMAIL:$_->parameter" >+ } >+ ); >+ } else { >+ _set_message_status( >+ { >+ message_id => $message->{'message_id'}, >+ status => 'failed', >+ failure_code => 'UNKNOWN_ERROR' >+ } >+ ); >+ } > return 0; > }; > return unless $email; >diff --git a/Koha/Email.pm b/Koha/Email.pm >index 5083af8bbd..a48ca5dd5d 100644 >--- a/Koha/Email.pm >+++ b/Koha/Email.pm >@@ -77,8 +77,7 @@ sub create { > > my $args = {}; > $args->{from} = $params->{from} || C4::Context->preference('KohaAdminEmailAddress'); >- Koha::Exceptions::BadParameter->throw("Invalid 'from' parameter: ".$args->{from}) >- unless Email::Valid->address( -address => $args->{from}, -fqdn => 0 ); # from is mandatory >+ Koha::Exceptions::BadParameter->throw( { parameter => 'from', error => "Invalid 'from' parameter: ".$args->{from} }) unless Email::Valid->address( -address => $args->{from}, -fqdn => 0 ); # from is mandatory > > $args->{subject} = $params->{subject} // ''; > >@@ -89,7 +88,7 @@ sub create { > $args->{to} = $params->{to}; > } > >- Koha::Exceptions::BadParameter->throw("Invalid 'to' parameter: ".$args->{to}) >+ Koha::Exceptions::BadParameter->throw({ parameter => 'to', error => "Invalid 'to' parameter: ".$args->{to}}) > unless Email::Valid->address( -address => $args->{to}, -fqdn => 0 ); # to is mandatory > > my $addresses = {}; >@@ -109,8 +108,8 @@ sub create { > } > > foreach my $address ( keys %{$addresses} ) { >- Koha::Exceptions::BadParameter->throw( >- "Invalid '$address' parameter: " . $addresses->{$address} ) >+ Koha::Exceptions::BadParameter->throw({ parameter => $address, error => >+ "Invalid '$address' parameter: " . $addresses->{$address} }) > if $addresses->{$address} and !Email::Valid->address( > -address => $addresses->{$address}, > -fqdn => 0 >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >index 5503654b66..f9d504226e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >@@ -95,7 +95,7 @@ > [% IF ( QUEUED_MESSAGE.failure_code ) %] > [% IF ( QUEUED_MESSAGE.failure_code == "INVALID_BORNUMBER" ) %]Invalid borrowernumber [% borrowernumber | html %] > [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_EMAIL' ) %]Unable to find an email address for this borrower >- [% ELSIF ( QUEUED_MESSAGE.failure_code == "INVALID_EMAIL" ) %]Invalid email address found [% borrowernumber | html %] >+ [% ELSIF (matches = QUEUED_MESSAGE.failure_code.match('INVALID_EMAIL:(\w+)') ) %]Invalid [% matches.0 | html %] email address found [% borrowernumber | html %] > [% ELSIF ( QUEUED_MESSAGE.failure_code == 'NO_FROM' ) %]Missing from email address > [% ELSIF ( QUEUED_MESSAGE.failure_code == 'MISSING_SMS' ) %]Missing SMS number > [% ELSIF ( QUEUED_MESSAGE.failure_code == 'DUPLICATE_MESSAGE' ) %]Message is duplicate >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28803
:
123469
|
123470
|
123475
|
123476
|
124000
|
124001
|
124131
|
124132
|
124746
|
124829
|
124878
|
124879
|
124880
|
124886
|
124887
|
124888
|
124900
|
124901
|
124902
|
125114
|
125115
|
125343
|
125344
|
125345
|
125346