From d273da4d53d1b8763c8864401503532ed77e1e48 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Mon, 17 Jun 2013 00:38:43 -0400 Subject: [PATCH] Support script-based circ in nearest_hold() The nearest_hold() implementation recently changed to pull in the circ library ID; however, if circulation runs through scripts, the circ library on the copy object has been fleshed, and the nearest hold routine gets very confused. Check to see if we do, in fact, have an object instead of a plain scalar, and assign the value to a placeholder variable accordingly. Thanks to Jeff Godin for his great assistance on debugging this! Signed-off-by: Dan Scott Signed-off-by: Mike Rylander Conflicts: Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm (Just whitespace. Resolved by hand. --miker) --- .../Application/Storage/Publisher/action.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 42e5e84951..7acb5fb7d5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -49,7 +49,7 @@ my %HOLD_SORT_ORDER_BY = ( sub isTrue { - my $v = shift; + my $v = shift || '0'; return 1 if ($v == 1); return 1 if ($v =~ /^t/io); return 1 if ($v =~ /^y/io); @@ -504,14 +504,23 @@ sub nearest_hold { my $age = shift() || '0 seconds'; my $fifo = shift(); - $log->info("deprecated 'fifo' param true, but ignored") if isTrue $fifo; + $log->info("deprecated 'fifo' param true, but ignored") if isTrue($fifo); + + # ScriptBuilder fleshes the circ_lib, which confuses things; ensure we + # are working with a circ lib ID and not an object + my $cp_circ_lib; + if (ref $cp->circ_lib) { + $cp_circ_lib = $cp->circ_lib->id; + } else { + $cp_circ_lib = $cp->circ_lib; + } my ($holdsort, $addl_cte, $addl_join) = build_hold_sort_clause(get_hold_sort_order($here), $cp, $here); local $OpenILS::Application::Storage::WRITE = 1; - my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $cp->circ_lib, $here, $cp->id, $age); + my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $cp_circ_lib, $here, $cp->id, $age); WITH go_home_interval AS ( SELECT OILS_JSON_TO_TEXT( (SELECT value FROM actor.org_unit_ancestor_setting( -- 2.43.2