From 22813f800eaaea6037507f36eaff8bd55127a2eb Mon Sep 17 00:00:00 2001 From: Liam Whalen Date: Thu, 11 Aug 2011 14:36:19 -0400 Subject: [PATCH] Fixed seaching for a colon (:) surrounded by white space When searching for a colon surrounded by white space the search would freeze. An example of such a search would be: Climate change economics and policy : an RFF anthology This was happening because the decompose function within QueryParser.pm Would build a regular expression that would search the query for both classes and class aliases e.g (keyword and kw). However, when buliding the regex for aliases QueryParser would add extraneous or symbols (|) to the end of the regex without adding the accompanying alias. This was happening because there was a check to see if the corresponding class to each alias had already been added to the regex. But, the check to see if the alias had already been appened to the regex happened too late. I have moved the check to encopase the appending of the or symbols and the class. Signed-off-by: Liam Whalen Signed-off-by: Mike Rylander --- .../perlmods/lib/OpenILS/Application/Storage/QueryParser.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm index 1b3a37f5fd..db9dd9839a 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm @@ -497,11 +497,13 @@ sub decompose { s/(^|[^|])\b$alias[:=]/$1$class:/g; } - $search_class_re .= '|' unless ($first_class); - $first_class = 0; + if (!$seen_classes{$class}) { + $search_class_re .= '|' unless ($first_class); + $first_class = 0; - $search_class_re .= $class . '(?:\|\w+)*' if (!$seen_classes{$class}); - $seen_classes{$class} = 1; + $search_class_re .= $class . '(?:\|\w+)*'; + $seen_classes{$class} = 1; + } } $search_class_re .= '):'; -- 2.11.0