Bug 15745: C4::Matcher gets CCL parsing error if term contains ? (question mark)
authorDavid Cook <dcook@prosentient.com.au>
Fri, 5 Feb 2016 05:09:45 +0000 (16:09 +1100)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Fri, 1 Apr 2016 19:12:51 +0000 (19:12 +0000)
Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>

Also fixes ! and +
Rebased to master
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
It makes perfect sense and works as expected. This part of the code is too
under-tested so no point requiring a regression test for such a simple change.

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>

C4/Matcher.pm

index 8cf1a99..9e04758 100644 (file)
@@ -651,7 +651,8 @@ sub get_matches {
             else {
                 my $phr = C4::Context->preference('AggressiveMatchOnISBN') ? ',phr' : q{};
                 $query = join( " or ",
-                    map { "$matchpoint->{'index'}$phr=$_" } @source_keys );
+                    map { "$matchpoint->{'index'}$phr=\"$_\"" } @source_keys );
+                    #NOTE: double-quote the values so you don't get a "Embedded truncation not supported" error when a term has a ? in it.
             }
 
             require C4::Search;
@@ -807,7 +808,7 @@ sub _get_match_keys {
             } else {
                 foreach my $subfield ($field->subfields()) {
                     if (exists $component->{'subfields'}->{$subfield->[0]}) {
-                        $string .= " " . $subfield->[1];
+                        $string .= " " . $subfield->[1]; #FIXME: It would be better to create an array and join with a space later...
                     }
                 }
                        }