@@ -, +, @@ fields in biblio 600 $9 11 $a Son Goku 600 $9 12 $a Vegeta 600 $9 11 $a Son Goku 600 $9 11 $a Son Goku - Set syspref dontmerge to 'Do' - Create a biblio record - Link a field to an authority (the field gets a $9). For example : 600 $9 11 $a Son Goku - Link a field to another authority (the field gets a $9). For example : 600 $9 12 $a Vegeta - Save the record - Index Zebra queue - Search for autority "Vegeta" - Click on "Merge" - Search for autority "Son Goku" - Click on "Merge" - Click on "Next" - Click on "Merge" - Go to biblio record - Test also with autoritites of different type. - Check that modifying the autority "Son Goku" impacts the biblio record --- C4/AuthoritiesMarc.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) --- a/C4/AuthoritiesMarc.pm +++ a/C4/AuthoritiesMarc.pm @@ -1518,6 +1518,21 @@ sub merge { my $auth_number=$field->subfield("9"); my $tag=$field->tag(); if ($auth_number==$mergefrom) { + # If merging distinct authorities, + # look if field to add already exists in the record + # in order to avoid a duplicate. + my $field_to_exists; + if ( $mergefrom != $mergeto ) { + foreach ( $marcrecord->field( $tag_to ? $tag_to : $tag ) ) { + if ( $_->subfield('9') && $_->subfield('9') == $mergeto ) { + $field_to_exists = 1; + last; + } + } + } + # Go editing + $marcrecord->delete_field($field); + unless ($field_to_exists) { 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 (grep {$_->[0] ne '9'} @record_to) { @@ -1530,8 +1545,8 @@ sub merge { foreach my $subfield (@restore) { $field_to->add_subfields($subfield->[0] =>$subfield->[1]); } - $marcrecord->delete_field($field); - $marcrecord->insert_grouped_field($field_to); + $marcrecord->insert_grouped_field($field_to); + } $update=1; } }#for each tag --