Bug 5264 (Retain additional bibliographic subfields when merging authorities) [for...
authorMarcel de Rooy <M.de.Rooy@rijksmuseum.nl>
Thu, 30 Sep 2010 08:03:16 +0000 (08:03 +0000)
committerGalen Charlton <gmcharlt@gmail.com>
Wed, 6 Oct 2010 12:47:28 +0000 (08:47 -0400)
The current code in AuthoritiesMarc.pm rewrites all subfields from the report
tag in the authority record to fields in related bibliographic records when
merging authorities. Additional subfields in the biblio records (e.g. relator
code or term) are lost in the process.

This patch retains the original algorithm but restores the additional subfields
from the original biblio record when rewriting the linked marc fields.

The problem also exists in 3.0. Two separate patches have been submitted.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
C4/AuthoritiesMarc.pm

index f6c9d35..b4a0d78 100644 (file)
@@ -1327,9 +1327,17 @@ sub merge {
                 my $tag=$field->tag();          
                 if ($auth_number==$mergefrom) {
                 my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto);
+               my $exclude='9';
                 foreach my $subfield (@record_to) {
                     $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
+                   $exclude.= $subfield->[0];
                 }
+               $exclude='['.$exclude.']';
+#              add subfields in $field not included in @record_to
+               my @restore= grep {$_->[0]!~/$exclude/} $field->subfields();
+                foreach my $subfield (@restore) {
+                   $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
+               }
                 $marcrecord->delete_field($field);
                 $marcrecord->insert_grouped_field($field_to);            
                 $update=1;