From d92b131fad6c2a9e133223ace5037574c6c19f75 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 26 Oct 2021 10:48:11 +0100 Subject: [PATCH] Bug 11175: (QA follow-up) Restore bug 29284 This patch restores the functional fixes introduced in bug 29284 and also prevents the 'Show analytics' link from displaying when no component parts are found and inline display is enabled. --- Koha/Biblio.pm | 17 ++++++++++++++++- catalogue/detail.pl | 4 +++- opac/opac-detail.pl | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index f325e5c0f4..8de5118607 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -498,7 +498,22 @@ 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 ( $errors, $results, $total_hits ); + eval { + ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); + }; + if ( $err || $@) { + my $error = q{}; + $error .= $err if $err; + $error .= $@ if $@; + warn "Warning from simple_search_compat: $error"; + $self->add_message( + { + type => 'error', + message => 'component_search', + } + ); + } $components = $results if defined($results) && @$results; } diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 3846777ebe..5caffefa0a 100755 --- a/catalogue/detail.pl +++ b/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 diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index aed49fde16..73ea3b46a0 100755 --- a/opac/opac-detail.pl +++ b/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 ); -- 2.20.1