From 71c1f6e9bac2c04e4322e3d6f93950006608e602 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 6 May 2022 08:10:04 +0100 Subject: [PATCH] Bug 30467: (QA follow-up) Restore indexing for item only deletion This patch restores indexing for item only bulk deletions. --- Koha/BackgroundJob/BatchDeleteItem.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Koha/BackgroundJob/BatchDeleteItem.pm b/Koha/BackgroundJob/BatchDeleteItem.pm index 49ec850a33..20c9d4510d 100644 --- a/Koha/BackgroundJob/BatchDeleteItem.pm +++ b/Koha/BackgroundJob/BatchDeleteItem.pm @@ -135,16 +135,19 @@ sub process { } # If there are no items left, delete the biblio - if ( $delete_biblios && @biblionumbers ) { + my @updated_biblionumbers; + if ( @biblionumbers ) { for my $biblionumber ( uniq @biblionumbers ) { my $items_count = Koha::Biblios->find($biblionumber)->items->count; - if ( $items_count == 0 ) { + if ( $delete_biblios && $items_count == 0 ) { my $error = C4::Biblio::DelBiblio( $biblionumber, { skip_record_index => 1 } ); unless ($error) { push @deleted_biblionumbers, $biblionumber; } + } else { + push @updated_biblionumbers, $biblionumber; } } @@ -156,6 +159,14 @@ sub process { 'recordDelete', "biblioserver", undef ); } } + + if (@updated_biblionumbers) { + my $indexer = Koha::SearchEngine::Indexer->new( + { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); + + $indexer->index_records( \@deleted_biblionumbers, + 'specialUpdate', "biblioserver", undef ); + } } ); } -- 2.20.1