Bugzilla – Attachment 134400 Details for
Bug 30464
BatchUpdateAuthority task does not deal with indexation correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30464: Make BatchUpdateAuthority update the index in one request
Bug-30464-Make-BatchUpdateAuthority-update-the-ind.patch (text/plain), 4.25 KB, created by
Tomás Cohen Arazi
on 2022-04-29 17:17:24 UTC
(
hide
)
Description:
Bug 30464: Make BatchUpdateAuthority update the index in one request
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2022-04-29 17:17:24 UTC
Size:
4.25 KB
patch
obsolete
>From a9ab0848ad8a649b605fe1ffbcc8f6e62879e4d6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 6 Apr 2022 13:45:21 +0200 >Subject: [PATCH] Bug 30464: Make BatchUpdateAuthority update the index in one > request > >Same as bug 30465 for authorities >--- > C4/AuthoritiesMarc.pm | 19 +++++++++++++++---- > Koha/BackgroundJob/BatchUpdateAuthority.pm | 7 ++++++- > 2 files changed, 21 insertions(+), 5 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 6245d89ec7..d2709070d8 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -545,7 +545,10 @@ returns authid of the newly created authority > > sub AddAuthority { > # pass the MARC::Record to this function, and it will create the records in the authority table >- my ($record,$authid,$authtypecode) = @_; >+ my ( $record, $authid, $authtypecode, $params ) = @_; >+ >+ my $skip_record_index = $params->{skip_record_index} || 0; >+ > my $dbh=C4::Context->dbh; > my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record > >@@ -654,8 +657,11 @@ sub AddAuthority { > $record->insert_fields_ordered( MARC::Field->new( '001', $authid ) ); > # Update > $dbh->do( "UPDATE auth_header SET authtypecode=?, marc=?, marcxml=? WHERE authid=?", undef, $authtypecode, $record->as_usmarc, $record->as_xml_record($format), $authid ) or die $DBI::errstr; >- my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); >- $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); >+ >+ unless ( $skip_record_index ) { >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); >+ $indexer->index_records( $authid, "specialUpdate", "authorityserver", $record ); >+ } > > _after_authority_action_hooks({ action => $action, authority_id => $authid }); > return ( $authid ); >@@ -697,13 +703,18 @@ sub DelAuthority { > Modifies authority record, optionally updates attached biblios. > The parameter skip_merge is optional and should be used with care. > >+skip_record_index will skip the indexation step. >+ > =cut > > sub ModAuthority { > my ( $authid, $record, $authtypecode, $params ) = @_; >+ >+ my $skip_record_index = $params->{skip_record_index} || 0; >+ > my $oldrecord = GetAuthority($authid); > #Now rewrite the $record to table with an add >- $authid = AddAuthority($record, $authid, $authtypecode); >+ $authid = AddAuthority($record, $authid, $authtypecode, { skip_record_index => $skip_record_index }); > merge({ mergefrom => $authid, MARCfrom => $oldrecord, mergeto => $authid, MARCto => $record }) if !$params->{skip_merge}; > logaction( "AUTHORITIES", "MODIFY", $authid, "authority BEFORE=>" . $oldrecord->as_formatted ) if C4::Context->preference("AuthoritiesLog"); > return $authid; >diff --git a/Koha/BackgroundJob/BatchUpdateAuthority.pm b/Koha/BackgroundJob/BatchUpdateAuthority.pm >index 9b5f89b7d7..6845a2d6cf 100644 >--- a/Koha/BackgroundJob/BatchUpdateAuthority.pm >+++ b/Koha/BackgroundJob/BatchUpdateAuthority.pm >@@ -23,6 +23,8 @@ use C4::AuthoritiesMarc qw( ModAuthority ); > use Koha::BackgroundJobs; > use Koha::DateUtils qw( dt_from_string ); > use Koha::MetadataRecord::Authority; >+use Koha::SearchEngine; >+use Koha::SearchEngine::Indexer; > > use base 'Koha::BackgroundJob'; > >@@ -81,7 +83,7 @@ sub process { > my $authority = Koha::MetadataRecord::Authority->get_from_authid( $authid ); > my $record = $authority->record; > ModifyRecordWithTemplate( $mmtid, $record ); >- ModAuthority( $authid, $record, $authority->authtypecode ); >+ ModAuthority( $authid, $record, $authority->authtypecode, { skip_record_index => 1 } ); > }; > if ( $error and $error != $authid or $@ ) { > push @messages, { >@@ -101,6 +103,9 @@ sub process { > $self->progress( ++$job_progress )->store; > } > >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); >+ $indexer->index_records( \@record_ids, "specialUpdate", "authorityserver", undef, { index_now => 1 } ); >+ > 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 30464
:
132990
|
134400
|
134401
|
134649