Bugzilla – Attachment 154313 Details for
Bug 33406
Searching for authority with hyphen surrounded by spaces causes error 500 (with ES)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33406: Handle ES search errors for authorities
Bug-33406-Handle-ES-search-errors-for-authorities.patch (text/plain), 3.53 KB, created by
Pedro Amorim
on 2023-08-08 08:51:20 UTC
(
hide
)
Description:
Bug 33406: Handle ES search errors for authorities
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-08-08 08:51:20 UTC
Size:
3.53 KB
patch
obsolete
>From 2b51fae56c2a91b753e3e26f79c094243dd8abee Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 11 May 2023 12:38:53 +0200 >Subject: [PATCH] Bug 33406: Handle ES search errors for authorities > >We are dealing ok with ES exceptions for biblio records search, >catching them and raising them to the end user. But we don't for >authorities, where we explode with an ugly 500. > >Test plan: >Search for "(term_1*) AND (-) AND (term_2*)" in the authority search and >notice that you don't get a 500 but an error instead saying that you >should try again > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >--- > authorities/authorities-home.pl | 33 ++++++++++++------- > .../modules/authorities/searchresultlist.tt | 4 +++ > 2 files changed, 25 insertions(+), 12 deletions(-) > >diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl >index e4f9bc471d..84122ed0e8 100755 >--- a/authorities/authorities-home.pl >+++ b/authorities/authorities-home.pl >@@ -88,18 +88,6 @@ if ( $op eq "do_search" ) { > my $resultsperpage = $query->param('resultsperpage') || 20; > my $offset = ( $startfrom - 1 ) * $resultsperpage + 1; > >- my $builder = Koha::SearchEngine::QueryBuilder->new( >- { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); >- my $searcher = Koha::SearchEngine::Search->new( >- { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); >- my $search_query = $builder->build_authorities_query_compat( >- [$marclist], [$and_or], [$excluding], [$operator], >- [$value], $authtypecode, $orderby >- ); >- my ( $results, $total ) = $searcher->search_auth_compat( >- $search_query, $offset, $resultsperpage >- ); >- > ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { > template_name => "authorities/searchresultlist.tt", >@@ -109,6 +97,27 @@ if ( $op eq "do_search" ) { > } > ); > >+ my $builder = Koha::SearchEngine::QueryBuilder->new( >+ { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); >+ my $searcher = Koha::SearchEngine::Search->new( >+ { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); >+ >+ my $search_query = $builder->build_authorities_query_compat( >+ [$marclist], [$and_or], [$excluding], [$operator], >+ [$value], $authtypecode, $orderby >+ ); >+ my ( $results, $total ); >+ eval { >+ ( $results, $total ) = $searcher->search_auth_compat( >+ $search_query, $offset, $resultsperpage >+ ); >+ }; >+ if ($@) { >+ my $query_error = q{}; >+ $query_error .= $@ if $@; >+ $template->param(query_error => $query_error); >+ } >+ > $template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate'); > $template->param( > csrf_token => Koha::Token->new->generate_csrf({ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >index 33a3479c72..686c80d57b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt >@@ -43,6 +43,10 @@ > > <div id="merge_in_progress" class="page-section bg-info" style="display:none;"></div> > <div class="page-section"> >+ [% IF ( query_error ) %] >+ <div class="dialog alert"><p><strong>Error:</strong> [% query_error | html %]</p></div> >+ [% END %] >+ > [% IF ( total ) %] > <div class="pages">[% pagination_bar | $raw %]</div> > >-- >2.30.2
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 33406
:
151067
|
154313
|
154314
|
155198
|
155199
|
155200
|
155611
|
155612
|
155613
|
155614
|
155818