Bug 8015: (follow-up) trap exceptions thrown by SetUTF8Flag()

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Leila <koha.aixmarseille@gmail.com>

Bug 8015: Catch error in the SetUTF8Flag routine

The eval avoids the interface to run endlessly if an error occurred.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Leila <koha.aixmarseille@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Jonathan Druart 2012-10-16 09:45:07 +02:00 committed by Galen Charlton
parent b38f0213fe
commit 0a176d4648
2 changed files with 22 additions and 19 deletions

View File

@ -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

View File

@ -26,7 +26,7 @@ use C4::Biblio;
use C4::Items;
use C4::Charset;
use C4::AuthoritiesMarc;
use Koha::MarcModificationTemplates;
use C4::MarcModificationTemplates;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -324,7 +324,7 @@ sub ModAuthInBatch {
=cut
sub BatchStageMarcRecords {
sub BatchStageMarcRecords {
my $record_type = shift;
my $encoding = shift;
my $marc_records = shift;