LP1076399: Prevent reactivated holds from expiring immediately.
authorJason Stephenson <jstephenson@mvlc.org>
Wed, 14 Nov 2012 18:41:37 +0000 (13:41 -0500)
committerBen Shum <bshum@biblio.org>
Tue, 18 Dec 2012 05:57:24 +0000 (00:57 -0500)
Clear the expire_time on deactivated holds.

Recalculate the expire_time when a hold is reactivated.

Upgrade script to set expire_time to NULL on frozen action.hold_requests.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql [new file with mode: 0644]

index 3e32d62..0b188bf 100644 (file)
@@ -1009,6 +1009,9 @@ sub update_hold_impl {
         $logger->info("clearing current_copy and check_time for frozen hold ".$hold->id);
         $hold->clear_current_copy;
         $hold->clear_prev_check_time;
+        # Clear expire_time to prevent frozen holds from expiring.
+        $logger->info("clearing expire_time for frozen hold ".$hold->id);
+        $hold->clear_expire_time;
     }
 
     # If the hold_expire_time is in the past && is not equal to the
@@ -1018,6 +1021,12 @@ sub update_hold_impl {
         $hold->expire_time(calculate_expire_time($hold->request_lib));
     }
 
+    # If the hold is reactivated, reset the expire_time.
+    if(!$U->is_true($hold->frozen) && $U->is_true($orig_hold->frozen)) {
+        $logger->info("Reset expire_time on activated hold ".$hold->id);
+        $hold->expire_time(calculate_expire_time($hold->request_lib));
+    }
+
     $e->update_action_hold_request($hold) or return $e->die_event;
     $e->commit;
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.frozen_holds_clear_expire_time.sql
new file mode 100644 (file)
index 0000000..2bd15b8
--- /dev/null
@@ -0,0 +1,11 @@
+-- LP1076399: Prevent reactivated holds from canceling immediately.
+-- Set the expire_time to NULL on all frozen/suspended holds.
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+UPDATE action.hold_request
+SET expire_time = NULL
+WHERE frozen = 't'; 
+
+COMMIT;