From df26e7abd08931fb203053377e7e51dfe574f8d7 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. JD amended patch: * remove trailing whitespaces * Move if inside first condition Signed-off-by: Jonathan Druart --- Koha/BackgroundJob/BatchDeleteItem.pm | 41 ++++++++++++++++----------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/Koha/BackgroundJob/BatchDeleteItem.pm b/Koha/BackgroundJob/BatchDeleteItem.pm index 49ec850a338..ce458a22201 100644 --- a/Koha/BackgroundJob/BatchDeleteItem.pm +++ b/Koha/BackgroundJob/BatchDeleteItem.pm @@ -135,26 +135,35 @@ sub process { } # If there are no items left, delete the biblio - if ( $delete_biblios && @biblionumbers ) { - for my $biblionumber ( uniq @biblionumbers ) { - my $items_count = - Koha::Biblios->find($biblionumber)->items->count; - if ( $items_count == 0 ) { - my $error = C4::Biblio::DelBiblio( $biblionumber, - { skip_record_index => 1 } ); - unless ($error) { - push @deleted_biblionumbers, $biblionumber; - } + my @updated_biblionumbers; + for my $biblionumber ( uniq @biblionumbers ) { + my $items_count = + Koha::Biblios->find($biblionumber)->items->count; + 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; } + } - if (@deleted_biblionumbers) { - my $indexer = Koha::SearchEngine::Indexer->new( - { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); + if (@deleted_biblionumbers) { + my $indexer = Koha::SearchEngine::Indexer->new( + { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); - $indexer->index_records( \@deleted_biblionumbers, - 'recordDelete', "biblioserver", undef ); - } + $indexer->index_records( \@deleted_biblionumbers, + '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.25.1