From 3b3c6794bfb436e95717a63497c75f6807c79160 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 6 Aug 2025 16:03:28 -0300 Subject: [PATCH] Bug 40608: Continue password change even if notification fails Content-Type: text/plain; charset=utf-8 When NotifyPasswordChange is enabled and GetPreparedLetter fails to find a PASSWORD_CHANGE letter template, the set_password method was returning early with undef, preventing the password from being changed. This fixes the issue by: 1. Removing the 'or return;' statement after GetPreparedLetter 2. Wrapping the letter processing in an if block to handle missing templates 3. Ensuring password change continues regardless of notification success The password change should not fail just because the notification cannot be sent. The notification is a nice-to-have feature, but the core functionality (changing the password) should always work. Test plan: 1. Apply the tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Patron.t => FAIL: Tests fail! 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Verify that when the letter template exists, notifications are still sent 6. Verify that when NotifyPasswordChange is disabled, password changes work 7. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Flater Signed-off-by: Tomas Cohen Arazi Signed-off-by: Marcel de Rooy --- Koha/Patron.pm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 3889d9be1a..50bdb2308c 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1121,17 +1121,19 @@ sub set_password { 'borrowers' => $self_from_storage->borrowernumber, }, want_librarian => 1, - ) or return; - - my $message_id = C4::Letters::EnqueueLetter( - { - letter => $letter, - borrowernumber => $self_from_storage->id, - to_address => $emailaddr, - message_transport_type => 'email' - } ); - C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; + + if ($letter) { + my $message_id = C4::Letters::EnqueueLetter( + { + letter => $letter, + borrowernumber => $self_from_storage->id, + to_address => $emailaddr, + message_transport_type => 'email' + } + ); + C4::Letters::SendQueuedMessages( { message_id => $message_id } ) if $message_id; + } } } } -- 2.39.5