From a7dde763dcb4e6f4d9d8a61e754f48758cbd03a4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 23 Sep 2020 18:57:26 +0000 Subject: [PATCH] Bug 25265: (follow-up) Don't index malformed records This is analogous to 26522, we shoudl skip record that cannot be retrieved for indexing Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- Koha/SearchEngine/Elasticsearch/Indexer.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/Indexer.pm b/Koha/SearchEngine/Elasticsearch/Indexer.pm index 49437cd268..87902a34e0 100644 --- a/Koha/SearchEngine/Elasticsearch/Indexer.pm +++ b/Koha/SearchEngine/Elasticsearch/Indexer.pm @@ -300,15 +300,19 @@ sub index_records { $biblionumbers = [$biblionumbers] if ref $biblionumbers ne 'ARRAY' && defined $biblionumbers; $records = [$records] if ref $records ne 'ARRAY' && defined $records; if ( $op eq 'specialUpdate' ) { + my $index_biblionumbers; unless ($records) { foreach my $biblionumber ( @$biblionumbers ){ my $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblionumber, embed_items => 1 }); - push @$records, $record; + if( $record ){ + push @$records, $record; + push @$index_biblionumbers, $biblionumber; + } } } - $self->update_index_background( $biblionumbers, $records ); + $self->update_index_background( $index_biblionumbers, $records ) if $index_biblionumbers && $records; } elsif ( $op eq 'recordDelete' ) { $self->delete_index_background( $biblionumbers ); -- 2.39.5