From de25b00a179e7f627282f609094d71e00909c855 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 24 Aug 2020 14:24:39 +0000 Subject: [PATCH] Bug 25273: (follow-up) Don't die on unknown authtype We are guessing authtype code and inserting the heading built accorindg to C4::Heading If we can't identify the auth type, we can format the heading. There is a record in the koha test data that is missing the heading field so type cannot be idenfitied This prevents us from dying n a record where we cannot identify the type. Note: This code will also be triggered for custom authority types, higlighting that they won't link because of hardcoded mappings in C4::Heading. We must tackle this on a new bug Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit 5a87514b2e44d64807422b29f719b29b0c9d1ba4) Signed-off-by: Lucas Gass (cherry picked from commit 401133b5b167708c4942d46d0ed164a2ceefbdfa) Signed-off-by: Aleisha Amohia --- Koha/SearchEngine/Elasticsearch.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index e634c2e11e..f63996e927 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -488,9 +488,13 @@ sub marc_records_to_documents { if ( $self->index eq 'authorities' ){ my $authtypecode = GuessAuthTypeCode( $record ); - my $field = $record->field( $auth_match_headings{ $authtypecode } ); - my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading - push @{$record_document->{'match-heading'}}, $heading->search_form if $heading; + if( $authtypecode ){ + my $field = $record->field( $auth_match_headings{ $authtypecode } ); + my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading + push @{$record_document->{'match-heading'}}, $heading->search_form if $heading; + } else { + warn "Cannot determine authority type for record: " . $record->field('001')->as_string; + } } my $mappings = $rules->{leader}; -- 2.39.5