[Koha-patches] [PATCH] [SIGNED OFF] Bug 5683 - it is possible to save corrupt records

Ian Walls ian.walls at bywatersolutions.com
Wed Feb 2 17:47:49 CET 2011


From: Jared Camins-Esakov <jcamins at bywatersolutions.com>

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 <ian.walls at bywatersolutions.com>
---
 C4/Biblio.pm |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 0cc63ab..b151d71 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
-- 
1.5.6.5



More information about the Koha-patches mailing list