From 3674ba36235364917925c7fce7aeaa9daa70026b Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 22 Jun 2021 16:41:55 -0300 Subject: [PATCH] Bug 28483: Remove warnings from Search.t There are too many warnings about uninitialized variables in Search.pm. This patch deals with that, the same way it is dealt accross the file: by setting an empty string when things are not defined. To test: 1. Run: $ kshell k$ prove t/db_dependent/Search.t => FAIL: Wow, too many warnings. Some related to this bug, some not. 2. Apply this patch 3. Repeat 1 => SUCCESS: No more warnings! 4. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall --- C4/Search.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 12f3b1fc5b..7161a06f5e 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1202,7 +1202,7 @@ sub buildQuery { my $weight_fields = C4::Context->preference("QueryWeightFields") || 0; my $fuzzy_enabled = C4::Context->preference("QueryFuzzy") || 0; - my $query = $operands[0]; + my $query = $operands[0] // ""; my $simple_query = $operands[0]; # initialize the variables we're passing back @@ -1356,7 +1356,7 @@ sub buildQuery { } # Detect Truncation - my $truncated_operand; + my $truncated_operand = q{}; my( $nontruncated, $righttruncated, $lefttruncated, $rightlefttruncated, $regexpr ) = _detect_truncation( $operand, $index ); @@ -1398,14 +1398,14 @@ sub buildQuery { warn "TRUNCATED OPERAND: >$truncated_operand<" if $DEBUG; # Handle Stemming - my $stemmed_operand; + my $stemmed_operand = q{}; $stemmed_operand = _build_stemmed_operand($operand, $lang) if $stemming; warn "STEMMED OPERAND: >$stemmed_operand<" if $DEBUG; # Handle Field Weighting - my $weighted_operand; + my $weighted_operand = q{}; if ($weight_fields) { $weighted_operand = _build_weighted_query( $operand, $stemmed_operand, $index ); $operand = $weighted_operand; @@ -1512,11 +1512,13 @@ sub buildQuery { $query =~ s/(?<=(st-date-normalized)):/=/g; # Removing warnings for later substitutions - $query //= q{}; - $query_desc //= q{}; - $query_cgi //= q{}; - $limit //= q{}; - $limit_desc //= q{}; + $query //= q{}; + $query_desc //= q{}; + $query_cgi //= q{}; + $limit //= q{}; + $limit_desc //= q{}; + $limit_cgi //= q{}; + $simple_query //= q{}; $limit =~ s/:/=/g; for ( $query, $query_desc, $limit, $limit_desc ) { s/ +/ /g; # remove extra spaces -- 2.39.5