From fc37c5943269491bca05178b53b8632a435ef69a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9rick=20Capovilla?= Date: Thu, 20 Oct 2011 12:05:02 -0400 Subject: [PATCH] Use MARCAuthorityControlField008 in AddAuthority for empty 008s The old default value for field 008 didn't have the correct length, which could potentially cause data corruptions. Uses the MARCAuthorityControlField008 preference added by BUG4839. http://bugs.koha-community.org/show_bug.cgi?id=7072 Signed-off-by: Jared Camins-Esakov Signed-off-by: Paul Poulain (cherry picked from commit 6408547cc0d396c8b9d29e1f7617637d9c12a9a6) Signed-off-by: Chris Nighswonger (cherry picked from commit df6f4d0c348b41882fdca8a5037870934c80f664) Signed-off-by: Chris Nighswonger --- C4/AuthoritiesMarc.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index d58798df8f..b3c50706b2 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -639,9 +639,16 @@ sub AddAuthority { } my $date=POSIX::strftime("%y%m%d",localtime); if (!$record->field('008')) { - $record->insert_fields_ordered( - MARC::Field->new('008',$date."|||a|||||| | ||| d") - ); + # Get a valid default value for field 008 + my $default_008 = C4::Context->preference('MARCAuthorityControlField008'); + if(!$default_008 or length($default_008)<34) { + $default_008 = '|| aca||aabn | a|a d'; + } + else { + $default_008 = substr($default_008,0,34); + } + + $record->insert_fields_ordered( MARC::Field->new('008',$date.$default_008) ); } if (!$record->field('040')) { $record->insert_fields_ordered( -- 2.39.5