From 85d9d524a8c837f66ef1a67a4e662d4676b3d232 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 --- C4/Search.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index b0ebedcb577..18ea9f02afb 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1197,7 +1197,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 @@ -1350,7 +1350,7 @@ sub buildQuery { } # Detect Truncation - my $truncated_operand; + my $truncated_operand = q{}; my( $nontruncated, $righttruncated, $lefttruncated, $rightlefttruncated, $regexpr ) = _detect_truncation( $operand, $index ); @@ -1392,14 +1392,14 @@ sub buildQuery { Koha::Logger->get->debug("TRUNCATED OPERAND: >$truncated_operand<"); # Handle Stemming - my $stemmed_operand; + my $stemmed_operand = q{}; $stemmed_operand = _build_stemmed_operand($operand, $lang) if $stemming; Koha::Logger->get->debug("STEMMED OPERAND: >$stemmed_operand<"); # 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; @@ -1506,11 +1506,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.20.1