Enhancement Bug 4444: Centralize Code Handling Perl Dependencies
[koha.git] / C4 / Search.pm
index 1161223..229ee40 100644 (file)
@@ -16,7 +16,7 @@ package C4::Search;
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
-# use warnings; # FIXME
+#use warnings; FIXME - Bug 2505
 require Exporter;
 use C4::Context;
 use C4::Biblio;    # GetMarcFromKohaField, GetBiblioData
@@ -1079,6 +1079,7 @@ sub buildQuery {
 
             # COMBINE OPERANDS, INDEXES AND OPERATORS
             if ( $operands[$i] ) {
+               $operands[$i]=~s/^\s+//;
 
               # A flag to determine whether or not to add the index to the query
                 my $indexes_set;
@@ -1122,14 +1123,14 @@ sub buildQuery {
                 }
 
                 # Set default structure attribute (word list)
-                my $struct_attr;
+                my $struct_attr = q{};
                 unless ( $indexes_set || !$index || $index =~ /(st-|phr|ext|wrdl)/ ) {
                     $struct_attr = ",wrdl";
                 }
 
                 # Some helpful index variants
-                my $index_plus       = $index . $struct_attr . ":" if $index;
-                my $index_plus_comma = $index . $struct_attr . "," if $index;
+                my $index_plus       = $index . $struct_attr . ':';
+                my $index_plus_comma = $index . $struct_attr . ',';
 
                 # Remove Stopwords
                 if ($remove_stopwords) {