From d1c8083b9ba1f6c82105365aedd18f454df2a435 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 6 Aug 2021 10:25:31 +0100 Subject: [PATCH] Bug 11175: (follow-up) More Fixes * Default to an empty arrayref from get_marc_components * Standardise search syntax in Koha::Util::Search --- Koha/Biblio.pm | 4 ++-- Koha/Util/Search.pm | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index d42e85968d..b76ca842f8 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -510,7 +510,7 @@ this object (MARC21 773$w points to this) sub get_marc_components { my ($self, $max_results) = @_; - return if (C4::Context->preference('marcflavour') ne 'MARC21'); + return [] if (C4::Context->preference('marcflavour') ne 'MARC21'); my $searchstr = Koha::Util::Search::get_component_part_query($self->id); @@ -520,7 +520,7 @@ sub get_marc_components { $self->{_components} = $results if ( defined($results) && scalar(@$results) ); } - return $self->{_components} || (); + return $self->{_components} || []; } =head3 subscriptions diff --git a/Koha/Util/Search.pm b/Koha/Util/Search.pm index fd35c846c4..a288600799 100644 --- a/Koha/Util/Search.pm +++ b/Koha/Util/Search.pm @@ -47,13 +47,13 @@ sub get_component_part_query { if ( !defined($pf003) ) { # search for 773$w='Host001' - $searchstr = "rcn=\"" . $pf001->data() . "\""; + $searchstr = "rcn:" . $pf001->data(); } else { $searchstr = "("; # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001') - $searchstr .= "(rcn=\"" . $pf001->data() . "\" AND cni=\"" . $pf003->data() . "\")"; - $searchstr .= " OR rcn=\"" . $pf003->data() . " " . $pf001->data() . "\""; + $searchstr .= "(rcn:" . $pf001->data() . " AND cni:" . $pf003->data() . ")"; + $searchstr .= " OR rcn:" . $pf003->data() . " " . $pf001->data(); $searchstr .= ")"; } @@ -66,6 +66,8 @@ sub get_component_part_query { $cleaned_title =~ tr|/||; $searchstr = "Host-item:($cleaned_title)"; } + + return $searchstr; } 1; -- 2.20.1