From ddcc60ff09f9528f251f94f22ae60b78e0025830 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Wed, 3 Dec 2025 09:04:19 +0200 Subject: [PATCH] Bug 41260: Ensure hold reminders are send for holds with waiting date on holiday If one runs cronjob holds_reminder.pl with both triggered and holidays parameter, reminders are not formed for holds which have same date as waiting date as library's closing date. This happens because triggered parameter changes crons functionality to handle only holds which waiting date is exactly the same one as variable $waiting_since. If date in holds waiting date is bypassed by above conditions, reminder is never formed. This patch adds new condition which checks that if triggered parameter is used and the date used in variable $waiting_date_static is a holiday. If both are true we use $waiting_date_static as a condition to search for holds waiting for pick up instead of skipping holidays with addDays method. To test: 1. Find hold which waiting date is 2 days from the day when you're testing this or update one holds waitingdate value directly from database. 2. Set day which is same as the holds waiting date as closing day from that library's calendar where hold is waiting in. 3. Run perl holds_reminder.pl -v -days 2 --triggered -holidays -c => Note that no reminder is formed for the hold. 4. Now run cron without triggered parameter. => Note that reminder is formed. 5. Apply this patch. 6. Run cron again with triggerred parameter. => Note that reminder is now formed. Sponsored-by: Koha-Suomi Oy --- misc/cronjobs/holds/holds_reminder.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/misc/cronjobs/holds/holds_reminder.pl b/misc/cronjobs/holds/holds_reminder.pl index 33ccfb37c8..ec704a3891 100755 --- a/misc/cronjobs/holds/holds_reminder.pl +++ b/misc/cronjobs/holds/holds_reminder.pl @@ -247,8 +247,16 @@ foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP #if today is a holiday skip sending the message next if $calendar->is_holiday($date_to_run); { - my $duration = DateTime::Duration->new( days => -$days ); - $waiting_date = $calendar->addDays( $date_to_run, $duration ); #Add negative of days + # IF parameter triggered is used and $waiting_date_static is holiday + # use $waiting_date_static as waiting since day to ensure that reminders + # are send correctly + my $is_waitingdate_holiday = $calendar->is_holiday($waiting_date_static); + if ( $triggered && $is_waitingdate_holiday ) { + $waiting_date = $waiting_date_static; + } else { + my $duration = DateTime::Duration->new( days => -$days ); + $waiting_date = $calendar->addDays( $date_to_run, $duration ); #Add negative of days + } } } else { $waiting_date = $waiting_date_static; -- 2.34.1