From 3d2f7253eaebaa109bf6c993c1e8fd2d5c123d38 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 5 Aug 2008 21:16:09 -0500 Subject: [PATCH] bug 2317: avoid crash when auto-creating authority If BiblioAddsAuthorities is ON, saving a MARC bib record in the cataloging editor can create new authority records. When using MARC21, if one of those authority records has diacritics in its heading, the save crashes with the following error: Wide character in null operation at /usr/local/share/perl/5.8.8/MARC/Charset/Table.pm line 96 To prevent this, new MARC21 authorities created by BiblioAddsAuthorities have the Leader/09 set to 'a'. Note that this is not currently required for UNIMARC authorities, as MARC::File::XML->as_xml_record() does not attempt to transcode UNIMARC records from MARC-8 to UTF-8. Signed-off-by: Joshua Ferraro --- cataloguing/addbiblio.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index f811c83c89..8e2f7b5ea7 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -32,6 +32,7 @@ use C4::Koha; # XXX subfield_is_koha_internal_p use C4::Branch; # XXX subfield_is_koha_internal_p use C4::ClassSource; use C4::ImportBatch; +use C4::Charset; use Date::Calc qw(Today); use MARC::File::USMARC; @@ -782,7 +783,19 @@ AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|); my $authfield=MARC::Field->new($authtypedata->{auth_tag_to_report},'','',"a"=>"".$field->subfield('a')); map { $authfield->add_subfields($_->[0]=>$_->[1]) if ($_->[0]=~/[A-z]/ && $_->[0] ne "a" )} $field->subfields(); $marcrecordauth->insert_fields_ordered($authfield); + + # bug 2317: ensure new authority knows it's using UTF-8; currently + # only need to do this for MARC21, as MARC::Record->as_xml_record() handles + # automatically for UNIMARC (by not transcoding) + # FIXME: AddAuthority() instead should simply explicitly require that the MARC::Record + # use UTF-8, but as of 2008-08-05, did not want to introduce that kind + # of change to a core API just before the 3.0 release. + if (C4::Context->preference('marcflavour') eq 'MARC21') { + SetMarcUnicodeFlag($marcrecordauth, 'MARC21'); + } + # warn "AUTH RECORD ADDED : ".$marcrecordauth->as_formatted; + my $authid=AddAuthority($marcrecordauth,'',$data->{authtypecode}); $countcreated++; $field->add_subfields('9'=>$authid); -- 2.39.5