Bugzilla – Attachment 161220 Details for
Bug 35165
Batch item deletions are run in a single transaction and cause locking issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35165: Tidy
Bug-35165-Tidy.patch (text/plain), 6.93 KB, created by
Nick Clemens (kidclamp)
on 2024-01-19 19:16:50 UTC
(
hide
)
Description:
Bug 35165: Tidy
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-01-19 19:16:50 UTC
Size:
6.93 KB
patch
obsolete
>From 10d49a9564c19b733c052790b4e21f6527ab88b2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 19 Jan 2024 19:12:48 +0000 >Subject: [PATCH] Bug 35165: Tidy > >--- > Koha/BackgroundJob/BatchDeleteItem.pm | 124 +++++++++++++------------- > 1 file changed, 60 insertions(+), 64 deletions(-) > >diff --git a/Koha/BackgroundJob/BatchDeleteItem.pm b/Koha/BackgroundJob/BatchDeleteItem.pm >index 6c15bbc1587..169fd8545ba 100644 >--- a/Koha/BackgroundJob/BatchDeleteItem.pm >+++ b/Koha/BackgroundJob/BatchDeleteItem.pm >@@ -94,92 +94,88 @@ sub process { > @deleted_biblionumbers ); > > try { >- my (@biblionumbers); >- for my $record_id ( sort { $a <=> $b } @record_ids ) { >+ my (@biblionumbers); >+ for my $record_id ( sort { $a <=> $b } @record_ids ) { > >- last if $self->get_from_storage->status eq 'cancelled'; >+ last if $self->get_from_storage->status eq 'cancelled'; > >- my $item = Koha::Items->find($record_id) || next; >+ my $item = Koha::Items->find($record_id) || next; > >- my $return = $item->safe_delete({ skip_record_index => 1, skip_holds_queue => 1 }); >- unless ( $return ) { >+ my $return = $item->safe_delete( { skip_record_index => 1, skip_holds_queue => 1 } ); >+ unless ($return) { > >- push @not_deleted_itemnumbers, $item->itemnumber; >- push @messages, >- { >- type => 'error', >- code => 'item_not_deleted', >- itemnumber => $item->itemnumber, >- biblionumber => $item->biblionumber, >- barcode => $item->barcode, >- title => $item->biblio->title, >- reason => @{$return->messages}[0]->message, >- }; >+ push @not_deleted_itemnumbers, $item->itemnumber; >+ push @messages, >+ { >+ type => 'error', >+ code => 'item_not_deleted', >+ itemnumber => $item->itemnumber, >+ biblionumber => $item->biblionumber, >+ barcode => $item->barcode, >+ title => $item->biblio->title, >+ reason => @{ $return->messages }[0]->message, >+ }; > >- next; >- } >+ next; >+ } > >- push @deleted_itemnumbers, $item->itemnumber; >- push @biblionumbers, $item->biblionumber; >+ push @deleted_itemnumbers, $item->itemnumber; >+ push @biblionumbers, $item->biblionumber; > >- $report->{total_success}++; >- $self->step; >- } >+ $report->{total_success}++; >+ $self->step; >+ } > >- # If there are no items left, delete the biblio >- 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, skip_holds_queue => 1 } ); >- unless ($error) { >- push @deleted_biblionumbers, $biblionumber; >- } >- } else { >- push @updated_biblionumbers, $biblionumber; >- } >+ # If there are no items left, delete the biblio >+ 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, skip_holds_queue => 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 >+ ); > >- Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >- { >- biblio_ids => \@deleted_biblionumbers >- } >- ) if C4::Context->preference('RealTimeHoldsQueue'); >- } >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => \@deleted_biblionumbers } ) >+ if C4::Context->preference('RealTimeHoldsQueue'); >+ } > >- if (@updated_biblionumbers) { >- my $indexer = Koha::SearchEngine::Indexer->new( >- { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); >+ if (@updated_biblionumbers) { >+ my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); > >- $indexer->index_records( \@updated_biblionumbers, >- 'specialUpdate', "biblioserver", undef ); >+ $indexer->index_records( >+ \@updated_biblionumbers, >+ 'specialUpdate', "biblioserver", undef >+ ); > >- Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >- { >- biblio_ids => \@updated_biblionumbers >- } >- ) if C4::Context->preference('RealTimeHoldsQueue'); >- } >- } >- catch { >+ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => \@updated_biblionumbers } ) >+ if C4::Context->preference('RealTimeHoldsQueue'); >+ } >+ } catch { > > warn $_; > > push @messages, >- { >+ { > type => 'error', > code => 'unknown', > error => $_, >- }; >+ }; > > }; > >-- >2.30.2
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 35165
:
161219
|
161220
|
161368
|
161369
|
161370
|
161480