From b72ede5a41e1903504c4ca337cf42462c81ea16f Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 24 Oct 2023 11:51:29 +0000 Subject: [PATCH] Bug 35141: Catch ES search exceptions in link_bibs_to_authorities, warn, and continue Content-Type: text/plain; charset=utf-8 This patch simplay adds an eval and a warning to link_bibs_to_authorities to catch any errors while searching and continue linking. To test: 1 - edit /etc/kohia/sites/kohadev/koha-conf.xml and add to elasticsearch stanza 0 2 - perl misc/link_bibs_to_authorities.pl 3 - It dies immediately 4 - Apply patch 5 - perl misc/link_bibs_to_authorities.pl 6 - Now it tries every record, throwing warnings along the way, but completes Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- misc/link_bibs_to_authorities.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/misc/link_bibs_to_authorities.pl b/misc/link_bibs_to_authorities.pl index f7cd876d26..08550c76c0 100755 --- a/misc/link_bibs_to_authorities.pl +++ b/misc/link_bibs_to_authorities.pl @@ -211,8 +211,17 @@ sub process_bib { my $frameworkcode = GetFrameworkCode($biblionumber); - my ( $headings_changed, $results ) = - LinkBibHeadingsToAuthorities( $linker, $record, $frameworkcode, $allowrelink, $tagtolink ); + my ( $headings_changed, $results ); + + eval { + ( $headings_changed, $results ) = + LinkBibHeadingsToAuthorities( $linker, $record, $frameworkcode, $allowrelink, $tagtolink ); + }; + if ($@) { + warn "Error while searching for authorities for biblionumber $biblionumber at " . localtime(time); + return; + } + foreach my $key ( keys %{ $results->{'unlinked'} } ) { $unlinked_headings{$key} += $results->{'unlinked'}->{$key}; } -- 2.30.2