From 5b69fc2acb7c51b2a692b0cc1fa6c791a4eab7e0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 31 Oct 2012 14:31:07 +0100 Subject: [PATCH] Bug 8015: Catch error in the SetUTF8Flag routine The eval avoids the interface to run endlessly if an error occurred. --- C4/Charset.pm | 37 ++++++++++++++++++++----------------- C4/ImportBatch.pm | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/C4/Charset.pm b/C4/Charset.pm index c294b36..fbfa8a5 100644 --- a/C4/Charset.pm +++ b/C4/Charset.pm @@ -131,23 +131,26 @@ But since it handles charset, and MARC::Record, it finds its way in that package =cut sub SetUTF8Flag{ - my ($record, $nfd)=@_; - return unless ($record && $record->fields()); - foreach my $field ($record->fields()){ - if ($field->tag()>=10){ - my @subfields; - foreach my $subfield ($field->subfields()){ - push @subfields,($$subfield[0],NormalizeString($$subfield[1],$nfd)); - } - my $newfield=MARC::Field->new( - $field->tag(), - $field->indicator(1), - $field->indicator(2), - @subfields - ); - $field->replace_with($newfield); - } - } + my ($record, $nfd)=@_; + return unless ($record && $record->fields()); + foreach my $field ($record->fields()){ + if ($field->tag()>=10){ + my @subfields; + foreach my $subfield ($field->subfields()){ + push @subfields,($$subfield[0],NormalizeString($$subfield[1],$nfd)); + } + eval { + my $newfield=MARC::Field->new( + $field->tag(), + $field->indicator(1), + $field->indicator(2), + @subfields + ); + $field->replace_with($newfield); + }; + warn "ERROR occurred in SetUTF8Flag $@" if $@; + } + } } =head2 NormalizeString diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 71a109c..20a9ab2 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -324,7 +324,7 @@ sub ModAuthInBatch { =cut -sub BatchStageMarcRecords { +sub BatchStageMarcRecords { my $record_type = shift; my $encoding = shift; my $marc_records = shift; -- 1.7.10.4