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 <jmf@liblime.com>
This commit is contained in:
parent
6e1869abcf
commit
3d2f7253ea
1 changed files with 13 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue