From 9bd9476b1d7c7b20c046213fd40910e0181b3757 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 15 Feb 2016 09:13:58 +0100 Subject: [PATCH] Bug 12426: [QA Follow-up] Clear to_address to force update When resending an email from the Notices tab in Patrons, we would like to use the recent email address. Test plan: [1] Look up a patron with some notices sent. [2] Adjust the patron email address (watch AutoEmailPrimaryAddress). [3] Resend the notice. Verify if the new address was used. Signed-off-by: Marcel de Rooy Signed-off-by: Brendan A Gallagher --- C4/Letters.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 5041ddc119..0452df2107 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1120,7 +1120,7 @@ sub GetMessage { Updates the message to 'pending' status so that it will be resent later on. - returns 1 on success, 0 on failure + returns 1 on success, 0 on failure, undef if no message was found =cut @@ -1130,13 +1130,18 @@ sub ResendMessage { my $message = GetMessage( $message_id ); return unless $message; + my $rv = 0; if ( $message->{status} ne 'pending' ) { - return ((C4::Letters::_set_message_status( { - message_id => $message_id, - status => 'pending', - } ) > 0) ? 1:0); + $rv = C4::Letters::_set_message_status({ + message_id => $message_id, + status => 'pending', + }); + $rv = $rv > 0? 1: 0; + # Clear destination email address to force address update + _update_message_to_address( $message_id, undef ) if $rv && + $message->{message_transport_type} eq 'email'; } - return 0; + return $rv; } =head2 _add_attachements -- 2.39.5