From a07ee4949c66e4f0eb19e7900f63ad6d4fc20622 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 7 Sep 2023 11:15:25 -0400 Subject: [PATCH] Bug 34731: Don't call SendQueuedMessages if message_id is bad Signed-off-by: David Nind --- C4/Auth_with_ldap.pm | 2 +- C4/Auth_with_shibboleth.pm | 2 +- Koha/Patron.pm | 2 +- Koha/Patron/Password/Recovery.pm | 3 +-- Koha/REST/V1/TwoFactorAuth.pm | 2 +- Koha/Ticket.pm | 7 +++---- basket/sendbasket.pl | 2 +- members/boraccount.pl | 4 ++-- members/memberentry.pl | 2 +- opac/opac-memberentry.pl | 4 ++-- opac/opac-registration-verify.pl | 2 +- opac/opac-sendbasket.pl | 2 +- opac/opac-sendshelf.pl | 2 +- pos/pay.pl | 2 +- virtualshelves/sendshelf.pl | 2 +- 15 files changed, 19 insertions(+), 21 deletions(-) diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm index f13dbdcf8e..422a59a45b 100644 --- a/C4/Auth_with_ldap.pm +++ b/C4/Auth_with_ldap.pm @@ -261,7 +261,7 @@ sub checkpw_ldap { } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; } } } else { diff --git a/C4/Auth_with_shibboleth.pm b/C4/Auth_with_shibboleth.pm index 364fd774b1..67552f3c89 100644 --- a/C4/Auth_with_shibboleth.pm +++ b/C4/Auth_with_shibboleth.pm @@ -169,7 +169,7 @@ sub _autocreate { message_transport_type => 'email' } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; } } return ( 1, $patron->cardnumber, $patron->userid ); diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 6937ea904a..1c9a518831 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -932,7 +932,7 @@ sub set_password { message_transport_type => 'email' } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; } } } diff --git a/Koha/Patron/Password/Recovery.pm b/Koha/Patron/Password/Recovery.pm index 1e462be368..879058488e 100644 --- a/Koha/Patron/Password/Recovery.pm +++ b/Koha/Patron/Password/Recovery.pm @@ -158,8 +158,7 @@ sub SendPasswordRecoveryEmail { } ); - my $num_letters_attempted = - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + my $num_letters_attempted = C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; return ($num_letters_attempted > 0); } diff --git a/Koha/REST/V1/TwoFactorAuth.pm b/Koha/REST/V1/TwoFactorAuth.pm index 9681fca16d..b999371e10 100644 --- a/Koha/REST/V1/TwoFactorAuth.pm +++ b/Koha/REST/V1/TwoFactorAuth.pm @@ -62,7 +62,7 @@ sub send_otp_token { message_transport_type => 'email' } ); - C4::Letters::SendQueuedMessages({message_id => $message_id}); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; my $message = C4::Letters::GetMessage($message_id); diff --git a/Koha/Ticket.pm b/Koha/Ticket.pm index bec743b783..83b84bc97e 100644 --- a/Koha/Ticket.pm +++ b/Koha/Ticket.pm @@ -131,8 +131,8 @@ sub store { borrowernumber => $self->reporter_id, } ); - C4::Letters::SendQueuedMessages( - { message_id => $acknowledgement_message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $acknowledgement_message_id } ) + if $acknowledgement_message_id; } # Notify cataloger by email @@ -156,8 +156,7 @@ sub store { reply_address => $self->reporter->notice_email_address, } ); - C4::Letters::SendQueuedMessages( - { message_id => $message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; } } } diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl index 3d5438fb42..e863497d32 100755 --- a/basket/sendbasket.pl +++ b/basket/sendbasket.pl @@ -111,7 +111,7 @@ if ($email_add) { } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; $template->param( SENT => 1 ); } diff --git a/members/boraccount.pl b/members/boraccount.pl index 72725b57f1..5398f28ea6 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -207,8 +207,8 @@ if ( $action eq 'send_receipt' ) { message_transport_type => 'email', } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); - $receipt_sent = 1; + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; + $receipt_sent = $message_id ? 1 : -1; } else { $receipt_sent = -1; diff --git a/members/memberentry.pl b/members/memberentry.pl index 64d9aa2aa7..70841759d7 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -450,7 +450,7 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ message_transport_type => 'email' } ); - SendQueuedMessages({ message_id => $message_id }); + SendQueuedMessages( { message_id => $message_id } ) if $message_id; }; if ($@) { $template->param( error_alert => $@ ); diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index d18e5f542b..ab99cb4e8c 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -211,7 +211,7 @@ if ( $action eq 'create' ) { C4::Context->preference('KohaAdminEmailAddress'), } ); - C4::Letters::SendQueuedMessages({ message_id => $message_id }); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; } else { $borrower{password} ||= Koha::AuthUtils::generate_password(Koha::Patron::Categories->find($borrower{categorycode})); @@ -279,7 +279,7 @@ if ( $action eq 'create' ) { message_transport_type => 'email' } ); - SendQueuedMessages({ message_id => $message_id }); + SendQueuedMessages( { message_id => $message_id } ) if $message_id; }; } } diff --git a/opac/opac-registration-verify.pl b/opac/opac-registration-verify.pl index 5cb30239da..60a004e18f 100755 --- a/opac/opac-registration-verify.pl +++ b/opac/opac-registration-verify.pl @@ -120,7 +120,7 @@ if ( message_transport_type => 'email' } ); - SendQueuedMessages({ message_id => $message_id }); + SendQueuedMessages( { message_id => $message_id } ) if $message_id; }; } } diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index ae0ec81e1c..d0ff9fc53a 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -110,7 +110,7 @@ if ( $email_add ) { } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; $template->param( SENT => 1 ); } diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index a90d2ca5f4..e08b474cb1 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -118,7 +118,7 @@ if ( $shelf and $shelf->can_be_viewed($borrowernumber) ) { } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; $template->param( SENT => 1 ); } diff --git a/pos/pay.pl b/pos/pay.pl index 871ffd6c19..495ffcdeec 100755 --- a/pos/pay.pl +++ b/pos/pay.pl @@ -116,7 +116,7 @@ if ( $action eq 'send' ) { ); # Send immediately - SendQueuedMessages( { message_id => $message_id } ); + SendQueuedMessages( { message_id => $message_id } ) if $message_id; # Set variables for template to allow printing still $template->param( diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index 3a2738c2d8..e50f3c3cd3 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -117,7 +117,7 @@ if ($to_address) { } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; $template->param( SENT => 1 ); } -- 2.30.2