From e25c42715ae88bb3691fb660cd5039d68b1f6166 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 2 May 2014 20:54:55 +0000 Subject: [PATCH] Bug 9016: (follow-up) treat missing transports for hold available notices as warnings, not fatal errors This patch fixes a situation where a patron that has preferences set for transport of a notice via a method that is not supported for that notice type can result in a failure. Rather than make it a fatal error during checkin, simply log a warning and skip. Signed-off-by: Galen Charlton --- C4/Reserves.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index ad866af229..5b0f0085d8 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1924,10 +1924,14 @@ sub _koha_notify_reserve { my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message. my $send_notification = sub { my ( $mtt, $letter_code ) = (@_); + return unless defined $letter_code; $letter_params{letter_code} = $letter_code; $letter_params{message_transport_type} = $mtt; - my $letter = C4::Letters::GetPreparedLetter ( %letter_params ) - or die "Could not find a letter called '$letter_params{'letter_code'}' for $mtt in the 'reserves' module"; + my $letter = C4::Letters::GetPreparedLetter ( %letter_params ); + unless ($letter) { + warn "Could not find a letter called '$letter_params{'letter_code'}' for $mtt in the 'reserves' module"; + return; + } C4::Letters::EnqueueLetter( { letter => $letter, @@ -1936,7 +1940,7 @@ sub _koha_notify_reserve { message_transport_type => $mtt, } ); }; - + while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { if ( ($mtt eq 'email' and not $to_address) or ($mtt eq 'sms' and not $borrower->{smsalertnumber}) ) { # email or sms is requested but not exist -- 2.39.5