Bugzilla – Attachment 132989 Details for
Bug 30460
BatchDeleteBiblio task does not deal with indexation correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30460: Make BatchDeleteBiblio update the index in one request
Bug-30460-Make-BatchDeleteBiblio-update-the-index-.patch (text/plain), 2.35 KB, created by
Jonathan Druart
on 2022-04-06 11:55:04 UTC
(
hide
)
Description:
Bug 30460: Make BatchDeleteBiblio update the index in one request
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-04-06 11:55:04 UTC
Size:
2.35 KB
patch
obsolete
>From c3e639023afadb68f68fcd8359c7d0d416e45cb2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 6 Apr 2022 13:20:12 +0200 >Subject: [PATCH] Bug 30460: Make BatchDeleteBiblio update the index in one > request > >No need to send 1 indexation request per item + 1 per biblio. > >Test plan: >Confirm that the batch biblio deletion tool still works correctly >--- > Koha/BackgroundJob/BatchDeleteBiblio.pm | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > >diff --git a/Koha/BackgroundJob/BatchDeleteBiblio.pm b/Koha/BackgroundJob/BatchDeleteBiblio.pm >index efd9af2bf4f..2f75bcf9b38 100644 >--- a/Koha/BackgroundJob/BatchDeleteBiblio.pm >+++ b/Koha/BackgroundJob/BatchDeleteBiblio.pm >@@ -3,9 +3,12 @@ package Koha::BackgroundJob::BatchDeleteBiblio; > use Modern::Perl; > use JSON qw( encode_json decode_json ); > >-use Koha::DateUtils qw( dt_from_string ); > use C4::Biblio; > >+use Koha::DateUtils qw( dt_from_string ); >+use Koha::SearchEngine; >+use Koha::SearchEngine::Indexer; >+ > use base 'Koha::BackgroundJob'; > > =head1 NAME >@@ -107,7 +110,7 @@ sub process { > # Delete items > my $items = Koha::Items->search({ biblionumber => $biblionumber }); > while ( my $item = $items->next ) { >- my $deleted = $item->safe_delete; >+ my $deleted = $item->safe_delete({ skip_record_index => 1 }); > unless ( $deleted ) { > push @messages, { > type => 'error', >@@ -124,7 +127,7 @@ sub process { > > # Finally, delete the biblio > my $error = eval { >- C4::Biblio::DelBiblio( $biblionumber ); >+ C4::Biblio::DelBiblio( $biblionumber, { skip_record_index => 1 } ); > }; > if ( $error or $@ ) { > push @messages, { >@@ -148,6 +151,15 @@ sub process { > $self->progress( ++$job_progress )->store; > } > >+ my @deleted_biblionumbers = >+ map { $_->{code} eq 'biblio_deleted' ? $_->{biblionumber} : () } >+ @messages; >+ >+ if ( @deleted_biblionumbers ) { >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >+ $indexer->index_records( \@deleted_biblionumbers, "recordDelete", "biblioserver" ); >+ } >+ > my $job_data = decode_json $self->data; > $job_data->{messages} = \@messages; > $job_data->{report} = $report; >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30460
:
132989
|
134402
|
134648