From 428556cd130db0cfcffd6fe081f32dc1218a904f Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Wed, 2 Feb 2011 11:47:49 -0500 Subject: [PATCH] Bug 5683 - it is possible to save corrupt records This patch makes it impossible to save records with variables fields that don't contain any subfields. Prior to this patch, link_bibs_to_authorities.pl would sometimes corrupt records. Signed-off-by: Ian Walls Signed-off-by: Chris Cormack --- C4/Biblio.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 0cc63ab69b..b151d71ae9 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -326,6 +326,14 @@ sub ModBiblio { $record->append_fields($field); } + foreach my $field ($record->fields()) { + if (! $field->is_control_field()) { + if (scalar($field->subfields()) == 0) { + $record->delete_fields($field); + } + } + } + # update biblionumber and biblioitemnumber in MARC # FIXME - this is assuming a 1 to 1 relationship between # biblios and biblioitems -- 2.39.2