From 8112e2a6361af871cada25c328ab9c04c0796fb7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sun, 15 Dec 2019 12:53:06 +0100 Subject: [PATCH] Bug 24243: Do not explode if invalid metadata when searching catalogue If the bibliographic record metadata cannot be decoded, the get_coins call should catch the exception raised by Koha::Biblio::Metadata->record to not explode Error is: "Invalid data, cannot decode objec" Test plan: 0/ Do not apply the patch 1/ Search for record at the OPAC 2/ Note one of the biblionumber from the first page result 3/ Set to empty string the biblio_metadata to make the error appears: update biblio_metadata set metadata="" where biblionumber=42; 4/ Try the same search => You get an internal server error 5/ Apply the patch, restart plack and try again => It now works, ie. it does not explode Signed-off-by: Liz Rea Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- opac/opac-search.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 105331009f..96264e4452 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -691,7 +691,8 @@ for (my $i=0;$i<@servers;$i++) { if (C4::Context->preference('COinSinOPACResults')) { my $biblio = Koha::Biblios->find( $res->{'biblionumber'} ); - $res->{coins} = $biblio ? $biblio->get_coins : q{}; # FIXME This should be moved at the beginning of the @newresults loop + # Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid + $res->{coins} = $biblio ? eval {$biblio->get_coins} : q{}; # FIXME This should be moved at the beginning of the @newresults loop } if ( C4::Context->preference( "Babeltheque" ) and $res->{normalized_isbn} ) { if( my $isbn = Business::ISBN->new( $res->{normalized_isbn} ) ) { -- 2.39.5