[Koha-patches] [PATCH] Bug 3955: Fixes leading space error in search.

Garry Collum gcollum at gmail.com
Fri Dec 18 19:52:56 CET 2009


Leading spaces in a search term were causing an error to be thrown in a join operator when auto-truncations is turned on. This patch removes the leading spaces.
---
 C4/Search.pm |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/C4/Search.pm b/C4/Search.pm
index 2fe57ed..e8903fc 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -932,8 +932,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;
-- 
1.6.0.4




More information about the Koha-patches mailing list