From cb7921d8d03219e0a8dfb350d0029c764c47f1bd Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 18 Jan 2024 14:46:45 +0100 Subject: [PATCH] Bug 35833: Silence few warnings from searching Resolve: [2024/01/18 11:31:24] [WARN] Use of uninitialized value $hits in numeric eq (==) at /usr/share/koha/opac/opac-search.pl line 612. [2024/01/18 11:31:24] [WARN] Use of uninitialized value $times in subtraction (-) at /usr/share/koha/C4/Search.pm line 1715. Test plan: Look for a few search expressions without results. Check log without and with patch. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Katrin Fischer --- C4/Search.pm | 2 +- opac/opac-search.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index e2de36571e..248856e42b 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1694,7 +1694,7 @@ sub searchResults { $times = $offset + $results_per_page; } else { - $times = $hits; # If less hits than results_per_page+offset we go to the end + $times = $hits // 0; # If less hits than results_per_page+offset we go to the end } my $marcflavour = C4::Context->preference("marcflavour"); diff --git a/opac/opac-search.pl b/opac/opac-search.pl index ae864ee30c..16b69332ff 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -608,7 +608,7 @@ for my $plugin_variables ( @plugin_responses ) { for (my $i=0;$i<@servers;$i++) { my $server = $servers[$i]; if ($server && $server =~/biblioserver/) { # this is the local bibliographic server - $hits = $results_hashref->{$server}->{"hits"}; + $hits = $results_hashref->{$server}->{"hits"} // 0; if ( $hits == 0 && $basic_search ){ $operands[0] = '"'.$operands[0].'"'; #quote it ## I. BUILD THE QUERY -- 2.39.5