Bug 28057: Use the biblioitem's biblionumber for checking availability

The loop here gets items from the record, plus analytic items. Because of this
we need to check more than 1 record - we decide to do this via biblioitems.

We need to preserve that, but when checking ItemsAnyAvailableAndNotRestricted we
cannot assume that the biblionumber and biblioitemnumber are the same (they should be
but this may not be the best of all possible worlds)

I simply switch the call here

To test:
1 - Apply patch
2 - Test placing holds on single bibs and multiple bibs
3 - Confirm it works as expected

Signed-off-by: Petro Vashchuk <stalkernoid@gmail.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2021-04-14 18:19:40 +00:00 committed by Kyle M Hall
parent 7091aeab8d
commit 8258ebe2fb
1 changed files with 3 additions and 4 deletions

View File

@ -404,8 +404,8 @@ foreach my $biblionumber (@biblionumbers) {
$biblioloopiter{noitems} = 1;
}
## Here we go backwards again to create hash of biblioitemnumber to itemnumbers,
## when by definition all of the itemnumber have the same biblioitemnumber
## Here we go backwards again to create hash of biblioitemnumber to itemnumbers
## this is important when we have analytic items which may be on another record
my ( $iteminfos_of );
while ( my $item = $items->next ) {
$item = $item->unblessed;
@ -415,7 +415,6 @@ foreach my $biblionumber (@biblionumbers) {
$iteminfos_of->{$itemnumber} = $item;
}
## Should be same as biblionumber
my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
my $biblioiteminfos_of = {
@ -463,7 +462,7 @@ foreach my $biblionumber (@biblionumbers) {
# (before this loop was inside that sub loop so it was O(n^2) )
my $items_any_available;
$items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioitemnumber, patron => $patron })
$items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioitem->{biblionumber}, patron => $patron })
if $patron;
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) {