Merge branch 'patroncards-wip' of git://git.foundations.edu/koha into community
[koha_ffzg] / C4 / Search.pm
index 8741072..be40b1b 100644 (file)
@@ -852,13 +852,15 @@ sub buildQuery {
 
     # pass nested queries directly
     # FIXME: need better handling of some of these variables in this case
-    if ( $query =~ /(\(|\))/ ) {
-        return (
-            undef,              $query, $simple_query, $query_cgi,
-            $query,             $limit, $limit_cgi,    $limit_desc,
-            $stopwords_removed, 'ccl'
-        );
-    }
+    # Nested queries aren't handled well and this implementation is flawed and causes users to be
+    # unable to search for anything containing () commenting out, will be rewritten for 3.4.0
+#    if ( $query =~ /(\(|\))/ ) {
+#        return (
+#            undef,              $query, $simple_query, $query_cgi,
+#            $query,             $limit, $limit_cgi,    $limit_desc,
+#            $stopwords_removed, 'ccl'
+#        );
+#    }
 
 # Form-based queries are non-nested and fixed depth, so we can easily modify the incoming
 # query operands and indexes and add stemming, truncation, field weighting, etc.
@@ -932,8 +934,10 @@ sub buildQuery {
                 }
 
                 if ($auto_truncation){
-                                       $operand=~join(" ",map{ "$_*" }split (/\s+/,$operand));
-                               }
+                   # join throws an error if there is a leading space
+                   $operand =~ s/^\s+//;
+                  $operand=~join(" ",map{ "$_*" }split (/\s+/,$operand));
+                }
 
                 # Detect Truncation
                 my $truncated_operand;
@@ -1090,7 +1094,9 @@ sub buildQuery {
     }
 
     # Normalize the query and limit strings
-    $query =~ s/:/=/g;
+    # This is flawed , means we can't search anything with : in it
+    # if user wants to do ccl or cql, start the query with that
+#    $query =~ s/:/=/g;
     $limit =~ s/:/=/g;
     for ( $query, $query_desc, $limit, $limit_desc ) {
         s/  / /g;    # remove extra spaces