From 64b3aee568cbe5ce3b8fb00f6ddd28cf728bf900 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 27 May 2022 13:07:04 +0000 Subject: [PATCH] Bug 30860: Get all items info for CanBookBeReserved on opac-reserve.pl Repeat test above on OPAC Signed-off-by: Andrew Fuerste-Henry --- opac/opac-reserve.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 85f2659a87..f927f26e93 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -428,6 +428,7 @@ foreach my $biblioNum (@biblionumbers) { # (before this loop was inside that sub loop so it was O(n^2) ) my $items_any_available; $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioNum, patron => $patron }) if $patron; + my $can_book_be_reserved = CanBookBeReserved( $borrowernumber, $biblioNum, undef, { return_all_items => 1 }); foreach my $item (@{$biblioData->{items}}) { my $item_info = $item->unblessed; @@ -468,8 +469,8 @@ foreach my $biblioNum (@biblionumbers) { # items_any_available defined outside of the current loop, # so we avoiding loop inside IsAvailableForItemLevelRequest: - my $policy_holdallowed = - CanItemBeReserved( $patron, $item )->{status} eq 'OK' && + my $policy_holdallowed &&= + $can_book_be_reserved->{$item->itemnumber}->{status} eq 'OK' && IsAvailableForItemLevelRequest($item, $patron, undef, $items_any_available); if ($policy_holdallowed) { @@ -530,7 +531,7 @@ foreach my $biblioNum (@biblionumbers) { } } - my $status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status}; + my $status = $can_book_be_reserved->{status}; $biblioLoopIter{holdable} &&= $status eq 'OK'; $biblioLoopIter{$status} = 1; -- 2.30.2