From e5d1bced257f96893a5e9126cfb51d66d86dc09f Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 19 Nov 2008 14:58:20 +0100 Subject: [PATCH] Adding some Error proof on GetAuthority return undef if there is a problem Signed-off-by: Galen Charlton --- C4/AuthoritiesMarc.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index b1029e67ce..6c56e09c30 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -711,8 +711,9 @@ sub GetAuthority { my $sth=$dbh->prepare("select authtypecode, marcxml from auth_header where authid=?"); $sth->execute($authid); my ($authtypecode, $marcxml) = $sth->fetchrow; - my $record=MARC::Record->new_from_xml(StripNonXmlChars($marcxml),'UTF-8', - (C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour"))); + my $record=eval {MARC::Record->new_from_xml(StripNonXmlChars($marcxml),'UTF-8', + (C4::Context->preference("marcflavour") eq "UNIMARC"?"UNIMARCAUTH":C4::Context->preference("marcflavour")))}; + return undef if ($@); $record->encoding('UTF-8'); if (C4::Context->preference("marcflavour") eq "MARC21") { my ($auth_type_tag, $auth_type_subfield) = get_auth_type_location($authtypecode); -- 2.39.5