@@ -, +, @@ --- catalogue/detail.pl | 29 +++++++++++++++-------------- opac/opac-detail.pl | 29 +++++++++++++++-------------- 2 files changed, 30 insertions(+), 28 deletions(-) --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -124,22 +124,23 @@ my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; if ( $xslfile ) { - my $searcher = Koha::SearchEngine::Search->new( - { index => $Koha::SearchEngine::BIBLIOS_INDEX } - ); - my $cleaned_title = $biblio->title; - $cleaned_title =~ tr|/||; - my $query = - ( C4::Context->preference('UseControlNumber') and $record->field('001') ) - ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)' - : "Host-item:($cleaned_title)"; - my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 ); - - warn "Warning from simple_search_compat: $err" - if $err; + my $analytics_count = 0; + eval { + my $searcher = Koha::SearchEngine::Search->new( + { index => $Koha::SearchEngine::BIBLIOS_INDEX } + ); + my $cleaned_title = $biblio->title; + $cleaned_title =~ tr|/||; + my $query = + ( C4::Context->preference('UseControlNumber') and $record->field('001') ) + ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)' + : "Host-item:($cleaned_title)"; + my ( $err, $result, $analytics_count ) = $searcher->simple_search_compat( $query, 0, 0 ); + warn "Warning from simple_search_compat: $err" if $err; + }; my $variables = { - show_analytics_link => $count > 0 ? 1 : 0 + show_analytics_link => $analytics_count > 0 ? 1 : 0 }; $template->param( --- a/opac/opac-detail.pl +++ a/opac/opac-detail.pl @@ -180,23 +180,24 @@ my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; if ( $xslfile ) { - my $searcher = Koha::SearchEngine::Search->new( - { index => $Koha::SearchEngine::BIBLIOS_INDEX } - ); - my $cleaned_title = $biblio->title; - $cleaned_title =~ tr|/||; - my $query = - ( C4::Context->preference('UseControlNumber') and $record->field('001') ) - ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)' - : "Host-item:($cleaned_title)"; - my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 ); - - warn "Warning from simple_search_compat: $err" - if $err; + my $analytics_count = 0; + eval { + my $searcher = Koha::SearchEngine::Search->new( + { index => $Koha::SearchEngine::BIBLIOS_INDEX } + ); + my $cleaned_title = $biblio->title; + $cleaned_title =~ tr|/||; + my $query = + ( C4::Context->preference('UseControlNumber') and $record->field('001') ) + ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)' + : "Host-item:($cleaned_title)"; + my ( $err, $result, $analytics_count ) = $searcher->simple_search_compat( $query, 0, 0 ); + warn "Warning from simple_search_compat: $err" if $err; + } my $variables = { anonymous_session => ($borrowernumber) ? 0 : 1, - show_analytics_link => $count > 0 ? 1 : 0 + show_analytics_link => $analytics_count > 0 ? 1 : 0 }; my @plugin_responses = Koha::Plugins->call( --