Bugzilla – Attachment 134639 Details for
Bug 30691
ElasticSearch Indexer crashes on authtypecode NAME_EVENT
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Skip unknown authtypes instead of dying
fix-bug-30691-ElasticSearch-Indexer-crashes-on-autht.patch (text/plain), 3.97 KB, created by
Thomas Klausner
on 2022-05-05 13:18:09 UTC
(
hide
)
Description:
Skip unknown authtypes instead of dying
Filename:
MIME Type:
Creator:
Thomas Klausner
Created:
2022-05-05 13:18:09 UTC
Size:
3.97 KB
patch
obsolete
>From e2fabbe95a49a91073e8a2545bc27209b0add785 Mon Sep 17 00:00:00 2001 >From: Thomas Klausner <domm@plix.at> >Date: Thu, 5 May 2022 15:06:41 +0200 >Subject: [PATCH 1208/1208] fix bug #30691 - ElasticSearch Indexer crashes on > authtypecode NAME_EVENT >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When GuessAuthTypeCode encounters a record containing tag 147, it >returns 'NAME_EVENT'. But in the default Koha installation, 'NAME_EVENT' >is not registered in auth_types: > >select * from auth_types where authtypecode = 'NAME_EVENT'; >Empty set (0.000 sec) > >This causes a bug in Koha/SearchEngine/Elasticsearch.pm:362, because >$field is undefined and then passed on to C4::Heading->new_from_field, >which dies: Can't call method "tag" on an undefined value at >/usr/share/koha/lib/C4/Heading.pm line 71 > >This simple fix just ignores and reports such cases (as done a few lines >further down in Koha/SearchEngine/Elasticsearch.pm, when there is no >$authtypecode. > >Test Plan: > >* Confirm that you do not have an authtype 'NAME_EVENT' (either in the > DB or /cgi-bin/koha/admin/authtypes.pl >* Enable ElasticSearch >* Create or edit an authoritiy record of type 'MEETI_NAME', make sure > that 111 is empty, and 147 has some content (you might even need to > fiddle with the frameworks to show the 147 form in the editor) >* Note the ID of the auth record >* Run the ES indexer, limited on the auth id: > bin/search_tools/rebuild_elasticsearch.pl -a -v -ai $YOUR_AUTH_ID >* The script will die with a message like: > > [2374] Committing final records... > Use of uninitialized value $tag in hash element at /usr/share/perl5/MARC/Record.pm line 202. > Use of uninitialized value $tag in regexp compilation at /usr/share/perl5/MARC/Record.pm line 206. > Use of uninitialized value $tag in hash element at /usr/share/perl5/MARC/Record.pm line 207. > Can't call method "tag" on an undefined value at /usr/share/koha/lib/C4/Heading.pm line 71. > >Now apply the patch. > >* Run ES indexer again >* It should now report something like > > [2374] Committing final records... > Cannot handle authority type NAME_EVENT for record: 1046314. It seems like this authority type is not defined in your instance at /usr/share/koha/lib/Koha/SearchEngine/Elasticsearch.pm line 566. > [2374] Total 1 records indexed > >Sponsored-by: Steiermärkische Landesbibliothel >--- > Koha/SearchEngine/Elasticsearch.pm | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index 85d8cba798..f3cb107e16 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -558,9 +558,14 @@ sub marc_records_to_documents { > my $authtypecode = GuessAuthTypeCode( $record ); > if( $authtypecode ){ > if( $authtypecode !~ m/_SUBD/ ){ #Subdivision records will not be used for linking and so don't require match-heading to be built >- my $field = $record->field( $auth_match_headings{ $authtypecode } ); >- my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading >- push @{$record_document->{'match-heading'}}, $heading->search_form if $heading; >+ if ($auth_match_headings{ $authtypecode }) { >+ my $field = $record->field( $auth_match_headings{ $authtypecode } ); >+ my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading >+ push @{$record_document->{'match-heading'}}, $heading->search_form if $heading; >+ } >+ else { >+ warn "Cannot handle authority type $authtypecode for record: " . $record->field('001')->as _string. ". It seems like this authority type is not defined in your instance."; >+ } > } > } else { > warn "Cannot determine authority type for record: " . $record->field('001')->as_string; >-- >2.25.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 30691
: 134639