From 2d27e406e8ca098b8bab0d158b726d6e0f037a1e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 19 Nov 2013 10:48:56 -0300 Subject: [PATCH] Bug 11096: wrap MARC::Record->new_from_xml call with eval Catch situations where MARC::Record would croak for bad-formed records. To test: - Run prove t/db_dependent/Search.t - It will fail at test 65 [1] - Apply the patch, it will warn for some failing records, but the tests will run smoothly. Regards To+ Sponsored-by: Universidad Nacional de Cordoba [1] a record that cannot be parsed by MARC::Record is simply skipped (bug 10684) --- C4/Search.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index c082dc0..732838c 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -506,10 +506,17 @@ sub getRecords { for my $facet (@$facets) { for ( my $j = 0 ; $j < $jmax ; $j++ ) { - my $marc_record = MARC::Record->new_from_xml( + my $marc_record = eval { MARC::Record->new_from_xml( $results[ $i - 1 ]->record($j)->raw(), 'UTF-8' - ); + ); }; + + if ( $@ ) { + warn "ERROR DECODING RECORD - $@: " . + $results[ $i - 1 ]->record($j)->raw(); + next; + } + my @used_datas = (); foreach my $tag ( @{ $facet->{tags} } ) { -- 1.8.3.2