From 80620880fdbe71a0f2041d6c7c04782a5763c5d5 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Wed, 1 Sep 2021 16:12:18 +0100
Subject: [PATCH] Bug 26314: (follow-up) Use clean_search_term

This patch uses the now public clean_search_term from bug 28316 to
sanitize the title string and prevent crashes in elastic search when
title contain reserved characters.

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
---
 Koha/Biblio.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm
index 2ce729649d..b49ec0c432 100644
--- a/Koha/Biblio.pm
+++ b/Koha/Biblio.pm
@@ -1649,6 +1649,8 @@ Returns a query which can be used to search for all component parts of MARC21 bi
 sub get_volumes_query {
     my ($self) = @_;
 
+    my $builder = Koha::SearchEngine::QueryBuilder->new(
+        { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
     my $marc = $self->metadata->record;
 
     my $searchstr;
@@ -1679,6 +1681,7 @@ sub get_volumes_query {
     else {
         my $cleaned_title = $marc->title;
         $cleaned_title =~ tr|/||;
+        $cleaned_title = $builder->clean_search_term($cleaned_title);
         $searchstr = "ti,phr:($cleaned_title)";
     }
 
-- 
2.30.2