From a3649905dfc7117bf566b234e06eaedc23e824c3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 6 May 2022 14:45:13 +0000 Subject: [PATCH] Bug 30710: Build holds queue once per biblio when batch deleting items Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Fridolin Somers --- C4/Biblio.pm | 2 +- Koha/BackgroundJob/BatchDeleteItem.pm | 16 ++++++++++++++-- Koha/Item.pm | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index f10f7b4754..aac46f025e 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -538,7 +538,7 @@ sub DelBiblio { { biblio_ids => [ $biblionumber ] } - ); + ) unless $params->{skip_holds_queue}; return; } diff --git a/Koha/BackgroundJob/BatchDeleteItem.pm b/Koha/BackgroundJob/BatchDeleteItem.pm index 578a095791..63e88142f1 100644 --- a/Koha/BackgroundJob/BatchDeleteItem.pm +++ b/Koha/BackgroundJob/BatchDeleteItem.pm @@ -108,7 +108,7 @@ sub process { my $item = Koha::Items->find($record_id) || next; - my $return = $item->safe_delete({ skip_record_index => 1 }); + my $return = $item->safe_delete({ skip_record_index => 1, skip_holds_queue => 1 }); unless ( $return ) { # FIXME Do we need to rollback the whole transaction if a deletion failed? @@ -141,7 +141,7 @@ sub process { Koha::Biblios->find($biblionumber)->items->count; if ( $delete_biblios && $items_count == 0 ) { my $error = C4::Biblio::DelBiblio( $biblionumber, - { skip_record_index => 1 } ); + { skip_record_index => 1, skip_holds_queue => 1 } ); unless ($error) { push @deleted_biblionumbers, $biblionumber; } @@ -156,6 +156,12 @@ sub process { $indexer->index_records( \@deleted_biblionumbers, 'recordDelete', "biblioserver", undef ); + + Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( + { + biblio_ids => \@deleted_biblionumbers + } + ); } if (@updated_biblionumbers) { @@ -164,6 +170,12 @@ sub process { $indexer->index_records( \@updated_biblionumbers, 'specialUpdate', "biblioserver", undef ); + + Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( + { + biblio_ids => \@updated_biblionumbers + } + ); } } ); diff --git a/Koha/Item.pm b/Koha/Item.pm index 312b2b4de6..a6e3c1fa84 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -248,7 +248,7 @@ sub delete { { biblio_ids => [ $self->biblionumber ] } - ); + ) unless $params->{skip_holds_queue}; return $result; } -- 2.39.5