From bb93a7ad1cb98559c1562f20485a576ea5832383 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Wed, 14 Nov 2012 11:49:49 -0500 Subject: [PATCH] Resolve LP893448: Prevent hold expiration in past. If a hold is placed with an expiration date in the past, the expire_time of the hold will be reset using the hold expiration interval settings. Likewise, if a hold is changed to have an expiration date in the past, the hold expiration date will be recalculated using the hold expiration interval settings. Signed-off-by: Jason Stephenson Signed-off-by: Ben Shum --- .../src/perlmods/lib/OpenILS/Application/Circ/Holds.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index 617f4de543..3e32d62604 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -315,6 +315,9 @@ sub create_hold { } } + # Check for hold expiration in the past, and set it to empty string. + $hold->expire_time(undef) if ($hold->expire_time && $U->datecmp($hold->expire_time) == -1); + # set the configured expire time unless($hold->expire_time) { $hold->expire_time(calculate_expire_time($recipient->home_ou)); @@ -1008,6 +1011,13 @@ sub update_hold_impl { $hold->clear_prev_check_time; } + # If the hold_expire_time is in the past && is not equal to the + # original expire_time, then reset the expire time to be in the + # future. + if ($hold->expire_time && $U->datecmp($hold->expire_time) == -1 && $U->datecmp($hold->expire_time, $orig_hold->expire_time) != 0) { + $hold->expire_time(calculate_expire_time($hold->request_lib)); + } + $e->update_action_hold_request($hold) or return $e->die_event; $e->commit; -- 2.43.2