From 036b19f4119cfde74acc4306ae6b3ae2302cb0b4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 23 Nov 2020 18:37:48 +0000 Subject: [PATCH] Bug 26957: Don't remove words that are also operators from search terms FindDuplicate has a hardcoded regex to remove 'and', 'or', and 'not' from any search fields, however, is does this with no regard for these terms being embedded in the middle of a word or phrase. E.g.: 'Coupland' becomes 'Coupl' 'Frog and toad' becomes 'frog toad' etc. This patch simplay removes the substitutions as we already quote the terms as well To test: 1 - Add records to your system like: The night circus by Erin Morgenstern Frog and toad all year Nothing ever happens 2 - Attempt to add purchase suggestions like title: the night circus, author:Morgenstern, Erin title: For and toad all year title:nothing ever happens (case is important) 3 - No warnings about existing biblios 4 - Apply patches 5 - Delete existing suggestions 6 - Repeat step 2 7 - Each attempt should warn you of existing biblio --- C4/Search.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index f2e73ee5a4..73d009f4bf 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -109,7 +109,6 @@ sub FindDuplicate { # FIXME: instead of removing operators, could just do # quotes around the value - $result->{title} =~ s/(and|or|not)//g; $query = "$titleindex:\"$result->{title}\""; if ( $result->{author} ) { $result->{author} =~ s /\\//g; @@ -118,7 +117,6 @@ sub FindDuplicate { $result->{author} =~ s /\)//g; # remove valid operators - $result->{author} =~ s/(and|or|not)//g; $query .= " $op $authorindex:\"$result->{author}\""; } } -- 2.11.0