Bugzilla – Attachment 134399 Details for
Bug 30459
BatchDeleteAuthority task does not deal with indexation correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30459: Make BatchDeleteAuthority update the index in one request
Bug-30459-Make-BatchDeleteAuthority-update-the-ind.patch (text/plain), 3.49 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-04-29 17:15:06 UTC
(
hide
)
Description:
Bug 30459: Make BatchDeleteAuthority update the index in one request
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-04-29 17:15:06 UTC
Size:
3.49 KB
patch
obsolete
>From 4a5bc1ea0f6ab9c8c7d3303841f1b7ac63cccfeb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 6 Apr 2022 13:52:40 +0200 >Subject: [PATCH] Bug 30459: Make BatchDeleteAuthority update the index in one > request > >Same as bug 30460 for authorities >--- > C4/AuthoritiesMarc.pm | 10 ++++++++-- > Koha/BackgroundJob/BatchDeleteAuthority.pm | 19 +++++++++++++++++-- > 2 files changed, 25 insertions(+), 4 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index d2709070d8..d6f2e381b3 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -675,12 +675,16 @@ Deletes $authid and calls merge to cleanup linked biblio records. > Parameter skip_merge is used in authorities/merge.pl. You should normally not > use it. > >+skip_record_index will skip the indexation step. >+ > =cut > > sub DelAuthority { > my ( $params ) = @_; > my $authid = $params->{authid} || return; > my $skip_merge = $params->{skip_merge}; >+ my $skip_record_index = $params->{skip_record_index} || 0; >+ > my $dbh = C4::Context->dbh; > > # Remove older pending merge requests for $authid to itself. (See bug 22437) >@@ -690,8 +694,10 @@ sub DelAuthority { > merge({ mergefrom => $authid }) if !$skip_merge; > $dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid ); > logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog"); >- my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); >- $indexer->index_records( $authid, "recordDelete", "authorityserver", undef ); >+ unless ( $skip_record_index ) { >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); >+ $indexer->index_records( $authid, "recordDelete", "authorityserver", undef ); >+ } > > _after_authority_action_hooks({ action => 'delete', authority_id => $authid }); > } >diff --git a/Koha/BackgroundJob/BatchDeleteAuthority.pm b/Koha/BackgroundJob/BatchDeleteAuthority.pm >index 3983ffd1e4..64d10f43ab 100644 >--- a/Koha/BackgroundJob/BatchDeleteAuthority.pm >+++ b/Koha/BackgroundJob/BatchDeleteAuthority.pm >@@ -3,9 +3,12 @@ package Koha::BackgroundJob::BatchDeleteAuthority; > use Modern::Perl; > use JSON qw( encode_json decode_json ); > >-use Koha::DateUtils qw( dt_from_string ); > use C4::AuthoritiesMarc; > >+use Koha::DateUtils qw( dt_from_string ); >+use Koha::SearchEngine; >+use Koha::SearchEngine::Indexer; >+ > use base 'Koha::BackgroundJob'; > > sub job_type { >@@ -46,7 +49,10 @@ sub process { > $schema->storage->txn_begin; > > my $authid = $record_id; >- eval { C4::AuthoritiesMarc::DelAuthority({ authid => $authid }) }; >+ eval { >+ C4::AuthoritiesMarc::DelAuthority( >+ { authid => $authid, skip_record_index => 1 } ); >+ }; > if ( $@ ) { > push @messages, { > type => 'error', >@@ -69,6 +75,15 @@ sub process { > $self->progress( ++$job_progress )->store; > } > >+ my @deleted_authids = >+ map { $_->{code} eq 'authority_deleted' ? $_->{authid} : () } >+ @messages; >+ >+ if ( @deleted_authids ) { >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); >+ $indexer->index_records( \@deleted_authids, "recordDelete", "authorityserver" ); >+ } >+ > my $job_data = decode_json $self->data; > $job_data->{messages} = \@messages; > $job_data->{report} = $report; >-- >2.34.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 30459
:
132991
|
134399
|
134647