Bug 24567: (QA follow-up) Remove warning in regex
authorJoonas Kylmälä <joonas.kylmala@helsinki.fi>
Tue, 3 Nov 2020 10:27:14 +0000 (12:27 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 4 Nov 2020 13:49:14 +0000 (14:49 +0100)
Without this patch we get

Use of uninitialized value $3 in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 943.

This converts the | OR operator to two different regexes so that the
capture group variables will be defined in every case.

Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/SearchEngine/Elasticsearch/QueryBuilder.pm

index 39cf1d2..a087b19 100644 (file)
@@ -940,7 +940,8 @@ sub _clean_search_term {
     }
 
     # Remove unquoted colons that have whitespace on either side of them
-    $term =~ s/((:+)(\s+)|(\s+)(:+))$lookahead/$3$4/g;
+    $term =~ s/(:+)(\s+)$lookahead/$2/g;
+    $term =~ s/(\s+)(:+)$lookahead/$1/g;
 
     $term = $self->_query_regex_escape_process($term);