From b99b8e3829f925bfba1b1cb5b63487a86b2d390f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 19 Nov 2013 10:48:56 -0300 Subject: [PATCH] [SIGNED OFF] 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) Signed-off-by: Katrin Fischer - All tests and QA script pass after applying the patch. - Verfied that sample record is not searchable before applying patch, but can be searched without problems after applying it. - Tested authority searching still workds as expected. - Tested bilbiographic searching still works as expected. - Simple search, also truncated search terms - Facetting - Advanced search, also itemtype and pubyear limits - Tested dontmerge preference, editing a linked authority and confirming the change is made to the linked records as well. Signed-off-by: Kyle M Hall --- C4/Search.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 9311722..11f0ba4 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