Bug 36438: Check object for calling metadata

Resolve: Can't call method "metadata" on an undefined value at catalogue/MARCdetail.pl line 93

The proceeding lines check for $record and respond appropriately.

Test plan:
Call catalogue/MARCdetail.pl with an unexisting biblionumber.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit a37ebc77b7)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 1d45bf88a9)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2024-03-27 12:19:34 +00:00 committed by Lucas Gass
parent b9d4408648
commit 8965898873

View file

@ -90,7 +90,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
);
my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio
my $record = $biblio_object->metadata->record({ embed_items => 1 });
my $record;
$record = $biblio_object->metadata->record({ embed_items => 1 }) if $biblio_object;
if ( not defined $record ) {
# biblionumber invalid -> report and exit