From 28ad32f574ef42ac18378f0aad357893622a7df4 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 14 Dec 2021 08:09:52 +0000 Subject: [PATCH] Bug 29690: (follow-up) Catch other cases This patch catches the rest of the cases in Koha::Biblio where `->metadata->record` may fail. --- Koha/Biblio.pm | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 2101fe28bc..d5cf1cbb50 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -426,9 +426,13 @@ sub host_items { elsif ( $marcflavour eq 'UNIMARC' ) { $analyticfield = '461'; } - my $marc_record = $self->metadata->record; + + my $record; + $record = eval { $self->metadata->record; }; + return if !$record; + my @itemnumbers; - foreach my $field ( $marc_record->field($analyticfield) ) { + foreach my $field ( $record->field($analyticfield) ) { push @itemnumbers, $field->subfield('9'); } @@ -848,7 +852,10 @@ sub is_serial { return 1 if $self->serial; - my $record = $self->metadata->record; + my $record; + eval { $record = $self->metadata->record }; + return 0 if !$record; + return 1 if substr($record->leader, 7, 1) eq 's'; return 0; @@ -886,12 +893,16 @@ sub custom_cover_image_url { if ( $url =~ $re ) { my $field = $+{field}; my $subfield = $+{subfield}; - my $marc_record = $self->metadata->record; + + my $record; + eval { $record = $self->metadata->record }; + return "" if !$record; + my $value; if ( $subfield ) { - $value = $marc_record->subfield( $field, $subfield ); + $value = $record->subfield( $field, $subfield ); } else { - my $controlfield = $marc_record->field($field); + my $controlfield = $record->field($field); $value = $controlfield->data() if $controlfield; } return unless $value; @@ -948,7 +959,7 @@ sub get_marc_notes { my $record; eval { $record = $self->metadata->record }; - return if !$record; + return [] if !$record; $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac ); -- 2.20.1