From a7732c6463c7e3949759e34087b6035c44c1480c Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 5 Feb 2020 15:51:24 +1100 Subject: [PATCH] Bug 24586: Gracefully fail authority lookup if PQF query invalid If Koha's query building has produced an invalid PQF query, don't throw a fatal error. Instead, trap the error, warn, and then skip the authority lookup for that field. Test Plan: I don't really have a good test plan at the moment. Enable AutoCreateAuthorities and BiblioAddsAuthorities maybe, and then try to do a search for 830$a with a value of the following: Bad "query" value --- C4/AuthoritiesMarc.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index c5b2131408..6b04066e89 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -248,8 +248,17 @@ sub SearchAuthorities { my @oAuth; my $i; $oAuth[0]=C4::Context->Zconn("authorityserver" , 1); - my $Anewq= new ZOOM::Query::PQF($query,$oAuth[0]); + my $Anewq; + eval { + $Anewq= new ZOOM::Query::PQF($query,$oAuth[0]); + }; + if ($@){ + warn "Bad PQF query: $@"; + } my $oAResult; + if ( ! $Anewq ){ + goto NOLUCK; + } $oAResult= $oAuth[0]->search($Anewq) ; while (($i = ZOOM::event(\@oAuth)) != 0) { my $ev = $oAuth[$i-1]->last_event(); @@ -336,7 +345,7 @@ sub SearchAuthorities { }## if nbresult NOLUCK: - $oAResult->destroy(); + $oAResult->destroy() if $oAResult; # $oAuth[0]->destroy(); return (\@finalresult, $nbresults); -- 2.16.4