Bugzilla – Attachment 122661 Details for
Bug 28682
Record detail page fails if error with search for analytics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28682: Protect search for analytics in record detail page
Bug-28682-Protect-search-for-analytics-in-record-d.patch (text/plain), 4.22 KB, created by
Fridolin Somers
on 2021-07-08 01:54:12 UTC
(
hide
)
Description:
Bug 28682: Protect search for analytics in record detail page
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2021-07-08 01:54:12 UTC
Size:
4.22 KB
patch
obsolete
>From 03cc79f28017e16ae96c9ea95105a8272854c1ef Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Wed, 7 Jul 2021 15:42:13 -1000 >Subject: [PATCH] Bug 28682: Protect search for analytics in record detail page > >In record detail page, there is a search for analytics, see Bug 15851. > >If for any reason this search fails, the page will be broken with 'Internal server error'. > >This patch adds a protection with eval. > >Test plan : >1) Use a Zebra install with no Elasticsearch configuration >2) Go to staff interface >3) Go to any record detail page : no error >4) Change preference 'SearchEngine' to 'Elasticsearch' >5) Refresh ecord detail page : check you have no error >6) Check a record with analytics link >7) Repeat 3 to 6 on OPAC >--- > catalogue/detail.pl | 29 +++++++++++++++-------------- > opac/opac-detail.pl | 29 +++++++++++++++-------------- > 2 files changed, 30 insertions(+), 28 deletions(-) > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index c282ecf6b8..2550d60ec1 100755 >--- a/catalogue/detail.pl >+++ b/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( >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 249de81618..62889fdff3 100755 >--- a/opac/opac-detail.pl >+++ b/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( >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28682
:
122661
|
123800