Bugzilla – Attachment 134856 Details for
Bug 30727
Holds queue updates can be called multiple times on batch record deletion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30727: Avoid holds queue updates multiple times on BatchDeleteBiblio
Bug-30727-Avoid-holds-queue-updates-multiple-times.patch (text/plain), 2.91 KB, created by
Martin Renvoize (ashimema)
on 2022-05-11 10:01:41 UTC
(
hide
)
Description:
Bug 30727: Avoid holds queue updates multiple times on BatchDeleteBiblio
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-05-11 10:01:41 UTC
Size:
2.91 KB
patch
obsolete
>From 8bc3f9b8bbc5fce22e13236c3b4717b2d971826e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 10 May 2022 12:27:02 -0300 >Subject: [PATCH] Bug 30727: Avoid holds queue updates multiple times on > BatchDeleteBiblio > >This patch makes the background job only enqueue holds queue updates >once per biblio, when appropriate. > >To test: >1. Apply the regression tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/BackgroundJobs/BatchDeleteBiblio.t >=> FAIL: It enqueues 3 times for a bib! >3. Apply this patch >4. Repeat 2 >=> SUCCESS: It only enqueues once! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/BackgroundJob/BatchDeleteBiblio.pm | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > >diff --git a/Koha/BackgroundJob/BatchDeleteBiblio.pm b/Koha/BackgroundJob/BatchDeleteBiblio.pm >index 2f75bcf9b3..d834f29b7c 100644 >--- a/Koha/BackgroundJob/BatchDeleteBiblio.pm >+++ b/Koha/BackgroundJob/BatchDeleteBiblio.pm >@@ -5,6 +5,7 @@ use JSON qw( encode_json decode_json ); > > use C4::Biblio; > >+use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::DateUtils qw( dt_from_string ); > use Koha::SearchEngine; > use Koha::SearchEngine::Indexer; >@@ -91,7 +92,7 @@ sub process { > my $holds = $biblio->holds; > while ( my $hold = $holds->next ) { > eval{ >- $hold->cancel; >+ $hold->cancel({ skip_holds_queue => 1 }); > }; > if ( $@ ) { > push @messages, { >@@ -110,7 +111,7 @@ sub process { > # Delete items > my $items = Koha::Items->search({ biblionumber => $biblionumber }); > while ( my $item = $items->next ) { >- my $deleted = $item->safe_delete({ skip_record_index => 1 }); >+ my $deleted = $item->safe_delete({ skip_record_index => 1, skip_holds_queue => 1 }); > unless ( $deleted ) { > push @messages, { > type => 'error', >@@ -127,7 +128,7 @@ sub process { > > # Finally, delete the biblio > my $error = eval { >- C4::Biblio::DelBiblio( $biblionumber, { skip_record_index => 1 } ); >+ C4::Biblio::DelBiblio( $biblionumber, { skip_record_index => 1, skip_holds_queue => 1 } ); > }; > if ( $error or $@ ) { > push @messages, { >@@ -158,6 +159,12 @@ sub process { > if ( @deleted_biblionumbers ) { > my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); > $indexer->index_records( \@deleted_biblionumbers, "recordDelete", "biblioserver" ); >+ >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >+ { >+ biblio_ids => \@deleted_biblionumbers >+ } >+ ); > } > > my $job_data = decode_json $self->data; >-- >2.20.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 30727
:
134820
|
134821
|
134840
|
134841
|
134855
| 134856