Protect against fleshed circ_lib in legacy check_age_protect
authorBill Erickson <berick@esilibrary.com>
Mon, 17 Sep 2012 12:48:26 +0000 (08:48 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 19 Sep 2012 14:17:15 +0000 (10:17 -0400)
Retrieving org settings with an org unit object as the context org unit
results in errors and dying.

This affects legacy scripts only.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Michael Peters <mrpeters@library.in.gov>

Open-ILS/src/perlmods/lib/OpenILS/Utils/PermitHold.pm

index c80a5d5..c453019 100644 (file)
@@ -162,8 +162,10 @@ sub check_age_protect {
                { order_by => 'age' }
        );
 
+    # circ_lib may be fleshed
+    my $context_org = ref $copy->circ_lib ? $copy->circ_lib->id : $copy->circ_lib;
     my $age_protect_date = $copy->create_date;
-    $age_protect_date = $copy->active_date if($U->ou_ancestor_setting_value($copy->circ_lib, 'circ.holds.age_protect.active_date'));
+    $age_protect_date = $copy->active_date if($U->ou_ancestor_setting_value($context_org, 'circ.holds.age_protect.active_date'));
 
     my $age = 0;
     my $age_protect_parsed;