Bugzilla – Attachment 174321 Details for
Bug 38270
Add MARCXML options to ElasticsearchMARCFormat
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38270: Tidy
Bug-38270-Tidy.patch (text/plain), 4.42 KB, created by
David Cook
on 2024-11-11 05:57:02 UTC
(
hide
)
Description:
Bug 38270: Tidy
Filename:
MIME Type:
Creator:
David Cook
Created:
2024-11-11 05:57:02 UTC
Size:
4.42 KB
patch
obsolete
>From ed09e2d2ce41cde491ff4f110866bda36b8099d3 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Mon, 11 Nov 2024 05:47:06 +0000 >Subject: [PATCH] Bug 38270: Tidy > >--- > Koha/SearchEngine/Elasticsearch.pm | 16 ++++++++-------- > Koha/SearchEngine/Elasticsearch/Search.pm | 20 ++++++++------------ > 2 files changed, 16 insertions(+), 20 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index ee5d9b6614..a403fb337d 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -806,13 +806,13 @@ sub marc_records_to_documents { > > # TODO: Perhaps should check if $records_document non empty, but really should never be the case > $record->encoding('UTF-8'); >- if ($marcformat_syspref eq 'ARRAY') { >+ if ( $marcformat_syspref eq 'ARRAY' ) { > $record_document->{'marc_data_array'} = $self->_marc_to_array($record); > $record_document->{'marc_format'} = 'ARRAY'; >- } elsif ($marcformat_syspref eq 'MARCXML'){ >+ } elsif ( $marcformat_syspref eq 'MARCXML' ) { > $record_document->{'marc_data'} = $record->as_xml_record($marcflavour); > $record_document->{'marc_format'} = 'MARCXML'; >- } elsif ($marcformat_syspref eq 'MARCXML_COMPRESSED'){ >+ } elsif ( $marcformat_syspref eq 'MARCXML_COMPRESSED' ) { > my $deflate = deflateInit( -Level => Z_BEST_COMPRESSION ); > my $output = ""; > if ($deflate) { >@@ -833,19 +833,19 @@ sub marc_records_to_documents { > local $SIG{__WARN__} = sub { > push @warnings, $_[0]; > }; >- $record_document->{'marc_data'} = encode_base64(encode('UTF-8', $record->as_usmarc())); >+ $record_document->{'marc_data'} = encode_base64( encode( 'UTF-8', $record->as_usmarc() ) ); > } > if (@warnings) { >+ > # Suppress warnings if record length exceeded >- unless (substr($record->leader(), 0, 5) eq '99999') { >+ unless ( substr( $record->leader(), 0, 5 ) eq '99999' ) { > foreach my $warning (@warnings) { > carp $warning; > } > } >- $record_document->{'marc_data'} = $record->as_xml_record($marcflavour); >+ $record_document->{'marc_data'} = $record->as_xml_record($marcflavour); > $record_document->{'marc_format'} = 'MARCXML'; >- } >- else { >+ } else { > $record_document->{'marc_format'} = 'base64ISO2709'; > } > } >diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm >index 81f0f19a34..7894717e54 100644 >--- a/Koha/SearchEngine/Elasticsearch/Search.pm >+++ b/Koha/SearchEngine/Elasticsearch/Search.pm >@@ -394,21 +394,17 @@ sub decode_record_from_result { > # Result is passed in as array, will get flattened > # and first element will be $result > my ( $self, $result ) = @_; >- if ($result->{marc_format} eq 'base64ISO2709') { >- return MARC::Record->new_from_usmarc(decode_base64($result->{marc_data})); >- } >- elsif ($result->{marc_format} eq 'MARCXML') { >- return MARC::Record->new_from_xml($result->{marc_data}, 'UTF-8', uc C4::Context->preference('marcflavour')); >- } >- elsif ($result->{marc_format} eq 'MARCXML_COMPRESSED') { >+ if ( $result->{marc_format} eq 'base64ISO2709' ) { >+ return MARC::Record->new_from_usmarc( decode_base64( $result->{marc_data} ) ); >+ } elsif ( $result->{marc_format} eq 'MARCXML' ) { >+ return MARC::Record->new_from_xml( $result->{marc_data}, 'UTF-8', uc C4::Context->preference('marcflavour') ); >+ } elsif ( $result->{marc_format} eq 'MARCXML_COMPRESSED' ) { > my $inflate = inflateInit(); > my $marcxml = $inflate->inflate( decode_base64( $result->{marc_data} ) ); > return MARC::Record->new_from_xml( $marcxml, 'UTF-8', uc C4::Context->preference('marcflavour') ); >- } >- elsif ($result->{marc_format} eq 'ARRAY') { >- return $self->_array_to_marc($result->{marc_data_array}); >- } >- else { >+ } elsif ( $result->{marc_format} eq 'ARRAY' ) { >+ return $self->_array_to_marc( $result->{marc_data_array} ); >+ } else { > Koha::Exceptions::Elasticsearch->throw("Missing marc_format field in Elasticsearch result"); > } > } >-- >2.39.5
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 38270
:
174320
|
174321
|
174322
|
174456
|
174457
|
174458