Bug 33497: Don't get host items if the MARC record is invalid

When don't want to explode with "invalid data" later so we need to
condition the host_item search

call trace was
        Koha::Biblio::Metadata::record('Koha::Biblio::Metadata=HASH(0x55ab92e60120)') called at /kohadevbox/koha/Koha/Biblio.pm line 538
        Koha::Biblio::_host_itemnumbers('Koha::Biblio=HASH(0x55ab92e4d5c0)') called at /kohadevbox/koha/Koha/Biblio.pm line 498
        Koha::Biblio::items('Koha::Biblio=HASH(0x55ab92e4d5c0)', 'HASH(0x55ab934615d8)') called at /kohadevbox/koha/catalogue/detail.pl line 200

This is fixing t/db_dependent/selenium/regressions.t

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 8bd5420312)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit a4896e3832)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2023-07-07 15:50:52 +02:00 committed by Matt Blenkinsop
parent d1536ebc2d
commit 33216808d6

View file

@ -194,13 +194,16 @@ my $all_items = $biblio->items->search_ordered;
my @items;
my $patron = Koha::Patrons->find( $borrowernumber );
$params->{ itemlost } = 0 if $patron->category->hidelostitems && !$showallitems;
my $items = $biblio->items({ host_items => 1 })->search_ordered( $params, { prefetch => ['issue','current_branchtransfers'] } );
my $items_params = {
( $invalid_marc_record ? () : ( host_items => 1 ) ),
};
my $items = $biblio->items($items_params)->search_ordered( $params, { prefetch => ['issue','current_branchtransfers'] } );
# flag indicating existence of at least one item linked via a host record
my $hostrecords = $biblio->host_items->count;
my $dat = &GetBiblioData($biblionumber);
$dat->{'count'} = $biblio->items({ host_items => 1 })->count;
$dat->{'count'} = $biblio->items($items_params)->count;
$dat->{'showncount'} = $items->count;
$dat->{'hiddencount'} = $dat->{'count'} - $dat->{'showncount'};