Bugzilla – Attachment 124887 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: Add invalid email handling in _send_message_by_email
Bug-28803-Add-invalid-email-handling-in-sendmessag.patch (text/plain), 3.20 KB, created by
Martin Renvoize (ashimema)
on 2021-09-15 13:15:49 UTC
(
hide
)
Description:
Bug 28803: Add invalid email handling in _send_message_by_email
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-09-15 13:15:49 UTC
Size:
3.20 KB
patch
obsolete
>From 5220ff33c3968ae09cff7621246efead7a8148a3 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 5 Aug 2021 08:00:19 +0100 >Subject: [PATCH] Bug 28803: Add invalid email handling in > _send_message_by_email > >This patch adds a try/catch block around the call to Koha::Email->create >to catch and handle invalid emails being passed in the parameters. > >The message is marked as 'failed' with an error_code of 'INVALID_EMAIL'. >--- > C4/Letters.pm | 41 ++++++++++++------- > .../prog/en/modules/members/notices.tt | 1 + > 2 files changed, 28 insertions(+), 14 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 87b82624c6..07a47380b1 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1389,20 +1389,33 @@ sub _send_message_by_email { > ); > return; > }; >- my $email = Koha::Email->create( >- { >- to => $to_address, >- ( >- C4::Context->preference('NoticeBcc') >- ? ( bcc => C4::Context->preference('NoticeBcc') ) >- : () >- ), >- from => $from_address, >- reply_to => $message->{'reply_address'} || $branch_replyto, >- sender => $branch_returnpath, >- subject => "" . $message->{subject} >- } >- ); >+ my $email = try { >+ Koha::Email->create( >+ { >+ to => $to_address, >+ ( >+ C4::Context->preference('NoticeBcc') >+ ? ( bcc => C4::Context->preference('NoticeBcc') ) >+ : () >+ ), >+ from => $from_address, >+ reply_to => $message->{'reply_address'} || $branch_replyto, >+ sender => $branch_returnpath, >+ subject => "" . $message->{subject} >+ } >+ ); >+ } >+ catch { >+ _set_message_status( >+ { >+ message_id => $message->{'message_id'}, >+ status => 'failed', >+ failure_code => 'INVALID_EMAIL' >+ } >+ ); >+ return 0; >+ }; >+ return unless $email; > > if ( $is_html ) { > $email->html_body( >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 31bd2dbb6f..5503654b66 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >@@ -95,6 +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 ( 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