Bug 10306: Allow controlfields in TransformKohaToMarc
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Thu, 20 Jul 2017 10:37:56 +0000 (12:37 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 7 Dec 2017 17:44:15 +0000 (14:44 -0300)
Since the interface allows you to connect a kohafield to a MARC
controlfield, this routine should be able to handle that. Unfortunately
it did not.

Test plan:
Change will be tested in Biblio/TransformKohaToMarc.t in the next patch.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

C4/Biblio.pm

index 5f696a2..51666e7 100644 (file)
@@ -2196,9 +2196,11 @@ sub TransformKohaToMarc {
         my @sfl = @{$tag_hr->{$tag}};
         @sfl = sort { $a->[0] cmp $b->[0]; } @sfl;
         @sfl = map { @{$_}; } @sfl;
-        $record->insert_fields_ordered(
-            MARC::Field->new($tag, " ", " ", @sfl)
-        );
+        # Special care for control fields: remove the subfield indication @
+        # and do not insert indicators.
+        my @ind = $tag < 10 ? () : ( " ", " " );
+        @sfl = grep { $_ ne '@' } @sfl if $tag < 10;
+        $record->insert_fields_ordered( MARC::Field->new($tag, @ind, @sfl) );
     }
     return $record;
 }