From 8a1d66740873009f0cc8d5b28598e9fd45df20bd Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 22 Jul 2022 15:49:22 -0300 Subject: [PATCH] Bug 29697: (follow-up) Indexing a deleted record is not expected to crash Signed-off-by: Tomas Cohen Arazi --- Koha/SearchEngine/Elasticsearch/Indexer.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/Indexer.pm b/Koha/SearchEngine/Elasticsearch/Indexer.pm index 9407a29882..6101a3a372 100644 --- a/Koha/SearchEngine/Elasticsearch/Indexer.pm +++ b/Koha/SearchEngine/Elasticsearch/Indexer.pm @@ -336,9 +336,18 @@ sub index_records { sub _get_record { my ( $self, $record_id ) = @_; - return $self->index eq $Koha::SearchEngine::BIBLIOS_INDEX - ? Koha::Biblios->find($record_id)->metadata->record({ embed_items => 1 }) - : C4::AuthoritiesMarc::GetAuthority($record_id); + + my $record; + + if ( $self->index eq $Koha::SearchEngine::BIBLIOS_INDEX ) { + my $biblio = Koha::Biblios->find($record_id); + $record = $biblio->metadata->record( { embed_items => 1 } ) + if $biblio; + } else { + $record = C4::AuthoritiesMarc::GetAuthority($record_id); + } + + return $record; } =head2 delete_index($biblionums) -- 2.39.5