From 621d5422e67709e0f116992b54ea1da2c6aec871 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 3 Dec 2020 06:48:13 -0500 Subject: [PATCH] Bug 27068: Fetch libraries once for speed Signed-off-by: Kyle M Hall --- C4/HoldsQueue.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index eb677e68cf..e24c10c4ba 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -370,13 +370,15 @@ sub GetItemsAvailableToFillHoldRequestsForBib { =cut +our $libraries = {}; sub _checkHoldPolicy { my ($item, $request) = @_; return 0 unless $item->{holdallowed}; return 0 if $item->{holdallowed} == 1 && $item->{homebranch} ne $request->{borrowerbranch}; - my $library = Koha::Libraries->find($item->{homebranch}); + $libraries->{$item->{homebranch}} ||= Koha::Libraries->find($item->{homebranch}); + my $library = $libraries->{$item->{homebranch}}; return 0 if $item->{'holdallowed'} == 3 && !$library->validate_hold_sibling({branchcode => $request->{borrowerbranch}}); @@ -386,7 +388,8 @@ sub _checkHoldPolicy { return 0 if $hold_fulfillment_policy eq 'homebranch' && $request->{branchcode} ne $item->{$hold_fulfillment_policy}; return 0 if $hold_fulfillment_policy eq 'holdingbranch' && $request->{branchcode} ne $item->{$hold_fulfillment_policy}; - my $patronLibrary = Koha::Libraries->find($request->{borrowerbranch}); + $libraries->{$request->{borrowerbranch}} ||= Koha::Libraries->find($request->{borrowerbranch}); + my $patronLibrary = $libraries->{$request->{borrowerbranch}}; return 0 if $hold_fulfillment_policy eq 'patrongroup' && !patronLibrary->validate_hold_sibling({branchcode => $request->{branchcode}}); -- 2.24.1 (Apple Git-126)