From b58e958153ec77d252859aef8e82010134b3dc26 Mon Sep 17 00:00:00 2001
From: Aleisha Amohia <aleishaamohia@hotmail.com>
Date: Mon, 1 May 2023 22:38:57 +0000
Subject: [PATCH] Bug 33348: (follow-up) Fix if no 008 defined
And copy fix across to Zebra search as well.
---
C4/AuthoritiesMarc.pm | 16 +++++++++-------
Koha/SearchEngine/Elasticsearch/Search.pm | 16 +++++++++-------
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm
index 02f9103de3b..adb453034a8 100644
--- a/C4/AuthoritiesMarc.pm
+++ b/C4/AuthoritiesMarc.pm
@@ -321,13 +321,15 @@ sub SearchAuthorities {
if ( C4::Context->preference('ShowHeadingUse') ) {
# checking valid heading use
my $f008 = $authrecord->field('008');
- my $pos14to16 = substr( $f008->data, 14, 3 );
- my $main = substr( $pos14to16, 0, 1 );
- $newline{main} = 1 if $main eq 'a';
- my $subject = substr( $pos14to16, 1, 1);
- $newline{subject} = 1 if $subject eq 'a';
- my $series = substr( $pos14to16, 2, 1 );
- $newline{series} = 1 if $series eq 'a';
+ if ( $f008 ) {
+ my $pos14to16 = substr( $f008->data, 14, 3 );
+ my $main = substr( $pos14to16, 0, 1 );
+ $newline{main} = 1 if $main eq 'a';
+ my $subject = substr( $pos14to16, 1, 1);
+ $newline{subject} = 1 if $subject eq 'a';
+ my $series = substr( $pos14to16, 2, 1 );
+ $newline{series} = 1 if $series eq 'a';
+ }
}
$newline{authtype} = defined($thisauthtype) ?
diff --git a/Koha/SearchEngine/Elasticsearch/Search.pm b/Koha/SearchEngine/Elasticsearch/Search.pm
index 8f7ae481b3b..5a4bf314090 100644
--- a/Koha/SearchEngine/Elasticsearch/Search.pm
+++ b/Koha/SearchEngine/Elasticsearch/Search.pm
@@ -249,13 +249,15 @@ sub search_auth_compat {
if ( C4::Context->preference('ShowHeadingUse') ) {
# checking valid heading use
my $f008 = $marc->field('008');
- my $pos14to16 = substr( $f008->data, 14, 3 );
- my $main = substr( $pos14to16, 0, 1 );
- $result{main} = 1 if $main eq 'a';
- my $subject = substr( $pos14to16, 1, 1);
- $result{subject} = 1 if $subject eq 'a';
- my $series = substr( $pos14to16, 2, 1 );
- $result{series} = 1 if $series eq 'a';
+ if ( $f008 ) {
+ my $pos14to16 = substr( $f008->data, 14, 3 );
+ my $main = substr( $pos14to16, 0, 1 );
+ $result{main} = 1 if $main eq 'a';
+ my $subject = substr( $pos14to16, 1, 1);
+ $result{subject} = 1 if $subject eq 'a';
+ my $series = substr( $pos14to16, 2, 1 );
+ $result{series} = 1 if $series eq 'a';
+ }
}
# Reimplementing BuildSummary is out of scope because it'll be hard
--
2.30.2