From 970cf815145b2f8e3d4a9e24a885373c25ba351f Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 12 Jul 2022 13:46:55 +0000 Subject: [PATCH] Bug 31023: Quote authtypecode in FindDuplicateAuthorities To test: 0 - Have Koha using Elasticsearch 1 - Set QueryRegexEscapeOptions to 'unescape escaped' 2 - Attempt to add a new 'GENRE/FORM' authority record 3 - On save you get a 500 error Unable to understand your search query, please rephrase and try again. at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/Search.pm line 102 4 - Apply patch, restart all 5 - Attempt to add a new 'GENRE/FORM' authority record 6 - Success! Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit dee864c1edff70f58dfaffcffa102e0663400425) Signed-off-by: Lucas Gass --- C4/AuthoritiesMarc.pm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index d6f2e381b3..4fafd5c165 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -784,15 +784,11 @@ Comments : an improvement would be to return All the records that match. sub FindDuplicateAuthority { my ($record,$authtypecode)=@_; -# warn "IN for ".$record->as_formatted; my $dbh = C4::Context->dbh; -# warn "".$record->as_formatted; my $auth_tag_to_report = Koha::Authority::Types->find($authtypecode)->auth_tag_to_report; -# warn "record :".$record->as_formatted." auth_tag_to_report :$auth_tag_to_report"; # build a request for SearchAuthorities my $op = 'AND'; - $authtypecode =~ s#/#\\/#; # GENRE/FORM contains forward slash which is a reserved character - my $query='at:'.$authtypecode.' '; + my $query='at:"'.$authtypecode.'" '; # Quote authtype code to avoid unescaping slash in GENRE/FORM later my $filtervalues=qr([\001-\040\Q!'"`#$%&*+,-./:;<=>?@(){[}_|~\E\]]); if ($record->field($auth_tag_to_report)) { foreach ($record->field($auth_tag_to_report)->subfields()) { -- 2.39.5