Bug 29284: (follow-up) Improve error logging to prevent warns
authorNick Clemens <nick@bywatersolutions.com>
Thu, 21 Oct 2021 10:26:12 +0000 (10:26 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 25 Oct 2021 12:08:06 +0000 (14:08 +0200)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
catalogue/detail.pl
opac/opac-detail.pl

index 76b4dbc..607634c 100644 (file)
@@ -986,6 +986,7 @@ sub clean_search_term {
     $term =~ s/((?<!\\)(?:[\\]{2})*:[^:\s]+(?<!\\)(?:[\\]{2})*)(?=:)/$1\\/g;
 
     # screen all exclamation signs that either are the last symbol or have white space after them
+    # or are followed by close parentheses
     $term =~ s/(?:[\s\\]*!\s*)+(\s|$|\))/$1/g;
 
     # screen all brackets with backslash
index 4efffed..7d6db51 100755 (executable)
@@ -147,12 +147,15 @@ my $marcflavour  = C4::Context->preference("marcflavour");
 
     };
     if ($err || $@){
-        warn "Warning from simple_search_compat: $err.$@";
+        my $error = q{};
+        $error .= $err if $err;
+        $error .= $@ if $@;
+        warn "Warning from simple_search_compat: $error";
         $template->param( analytics_error => 1 );
     }
 
     my $variables = {
-        show_analytics_link => $count > 0 ? 1 : 0
+        show_analytics_link => defined $count && $count > 0 ? 1 : 0
     };
 
     $template->param(
index 36c64d4..9e12ef8 100755 (executable)
@@ -217,12 +217,15 @@ my $ean = GetNormalizedEAN( $record, $marcflavour );
 
     };
     if ($err || $@){
-        warn "Warning from simple_search_compat: $err.$@";
+        my $error = q{};
+        $error .= $err if $err;
+        $error .= $@ if $@;
+        warn "Warning from simple_search_compat: $error";
     }
 
     my $variables = {
         anonymous_session   => ($borrowernumber) ? 0 : 1,
-        show_analytics_link => $count > 0 ? 1 : 0
+        show_analytics_link => defined $count && $count > 0 ? 1 : 0
     };
 
     my $lang   = C4::Languages::getlanguage();