Browse Source

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.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Amended: Fixed error with $err vs $error(s) :)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.11.x
Martin Renvoize 3 years ago
committed by Jonathan Druart
parent
commit
012d2333b2
  1. 16
      Koha/Biblio.pm
  2. 4
      catalogue/detail.pl
  3. 2
      opac/opac-detail.pl

16
Koha/Biblio.pm

@ -498,7 +498,21 @@ sub get_marc_components {
my $components; my $components;
if (defined($searchstr)) { if (defined($searchstr)) {
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); 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; $components = $results if defined($results) && @$results;
} }

4
catalogue/detail.pl

@ -200,7 +200,8 @@ my $showcomp = C4::Context->preference('ShowComponentRecords');
my $show_analytics; my $show_analytics;
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { 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; my $parts;
for my $part ( @{$components} ) { for my $part ( @{$components} ) {
$part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); $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 } else { # check if we should show analytics anyway
$show_analytics = 1 if @{$biblio->get_marc_components(1)}; # count matters here, results does not $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 # XSLT processing of some stuff

2
opac/opac-detail.pl

@ -630,7 +630,7 @@ my $showcomp = C4::Context->preference('ShowComponentRecords');
my ( $parts, $show_analytics ); my ( $parts, $show_analytics );
if ( $showcomp eq 'both' || $showcomp eq 'opac' ) { if ( $showcomp eq 'both' || $showcomp eq 'opac' ) {
if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { 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} ) { for my $part ( @{$components} ) {
$part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); $part = C4::Search::new_record_from_zebra( 'biblioserver', $part );
my $id = Koha::SearchEngine::Search::extract_biblionumber( $part ); my $id = Koha::SearchEngine::Search::extract_biblionumber( $part );

Loading…
Cancel
Save