Bug 27068: Don't 'cache' Koha::Libraries

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-02-12 12:10:31 +01:00
parent fac4c54ead
commit 20c97bca2d
1 changed files with 3 additions and 10 deletions

View File

@ -370,28 +370,21 @@ 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};
$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}});
return 0 if $item->{'holdallowed'} == 3 && !Koha::Libraries->find($item->{homebranch})->validate_hold_sibling({branchcode => $request->{borrowerbranch}});
my $hold_fulfillment_policy = $item->{hold_fulfillment_policy};
return 0 if $hold_fulfillment_policy eq 'holdgroup' && !$library->validate_hold_sibling({branchcode => $request->{branchcode}});
return 0 if $hold_fulfillment_policy eq 'holdgroup' && !Koha::Libraries->find($item->{homebranch})->validate_hold_sibling({branchcode => $request->{branchcode}});
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};
$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}});
return 0 if $hold_fulfillment_policy eq 'patrongroup' && !Koha::Libraries->find($request->{borrowerbranch})->validate_hold_sibling({branchcode => $request->{branchcode}});
return 1;