@@ -, +, @@ --- Koha/Biblio.pm | 16 +++++++++++++++- catalogue/detail.pl | 4 +++- opac/opac-detail.pl | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -498,7 +498,21 @@ sub get_marc_components { my $components; if (defined($searchstr)) { my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); - my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); + my ( $error, $results, $total_hits ); + eval { + ( $error, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); + }; + if( $error || $@ ) { + $error //= q{}; + $error .= $@ if $@; + warn "Warning from simple_search_compat: $error"; + $self->add_message( + { + type => 'error', + message => 'component_search', + } + ); + } $components = $results if defined($results) && @$results; } --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -200,7 +200,8 @@ my $showcomp = C4::Context->preference('ShowComponentRecords'); my $show_analytics; if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { - $show_analytics = 1; # just show link when having results + $show_analytics = 1 if @{$components}; # just show link when having results + $template->param( analytics_error => 1 ) if @{$biblio->messages}; my $parts; for my $part ( @{$components} ) { $part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); @@ -221,6 +222,7 @@ if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { } } else { # check if we should show analytics anyway $show_analytics = 1 if @{$biblio->get_marc_components(1)}; # count matters here, results does not + $template->param( analytics_error => 1 ) if @{$biblio->messages}; } # XSLT processing of some stuff --- a/opac/opac-detail.pl +++ a/opac/opac-detail.pl @@ -630,7 +630,7 @@ my $showcomp = C4::Context->preference('ShowComponentRecords'); my ( $parts, $show_analytics ); if ( $showcomp eq 'both' || $showcomp eq 'opac' ) { if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { - $show_analytics = 1; # just show link when having results + $show_analytics = 1 if @{$components}; # just show link when having results for my $part ( @{$components} ) { $part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); my $id = Koha::SearchEngine::Search::extract_biblionumber( $part ); --