From b6acfae6ac5e6925f167dbab5c0db0e381754a77 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Mon, 13 Aug 2012 17:04:05 +0200
Subject: [PATCH] Bug 8015: Followup: FIX cp and mv if subfields don't exist.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
---
 Koha/SimpleMARC.pm |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm
index 3dda39c..760820a 100644
--- a/Koha/SimpleMARC.pm
+++ b/Koha/SimpleMARC.pm
@@ -126,6 +126,13 @@ sub update_field {
       foreach my $field ( @fields ) {
         $field->update( "$subfieldName" => $values[$i++] );
       }
+      if ( $i <= scalar @values - 1 ) {
+        foreach my $field ( @fields ) {
+          foreach my $j ( $i .. scalar( @values ) - 1) {
+            $field->add_subfields( "$subfieldName" => $values[$j] );
+          }
+        }
+      }
     } else {
       ## Field does not exist, create it.
       foreach my $value ( @values ) {
-- 
1.7.2.5