Bugzilla – Attachment 134649 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.34 KB, created by
Martin Renvoize
on 2022-05-05 14:58:03 UTC
(
hide
)
Description:
Bug 30464: Make BatchUpdateAuthority update the index in one request
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2022-05-05 14:58:03 UTC
Size:
4.34 KB
patch
obsolete
>From 0c88e4eebc9da8bef9b718ee08682cdbc920cecc 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 > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > 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..ca23f7cf86 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" ); >+ > my $job_data = decode_json $self->data; > $job_data->{messages} = \@messages; > $job_data->{report} = $report; >-- >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 30464
:
132990
|
134400
|
134401
| 134649