View | Details | Raw Unified | Return to bug 17913
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-8 / +13 lines)
Lines 1467-1472 sub merge { Link Here
1467
    # BulkEdit marc records
1467
    # BulkEdit marc records
1468
    # May be used as a template for a bulkedit field  
1468
    # May be used as a template for a bulkedit field  
1469
    my $overwrite = C4::Context->preference( 'AuthorityMergeMode' ) eq 'strict';
1469
    my $overwrite = C4::Context->preference( 'AuthorityMergeMode' ) eq 'strict';
1470
    my $skip_subfields = $overwrite
1471
        # This hash contains all subfields from the authority report fields
1472
        # Including $MARCfrom as well as $MARCto
1473
        # We only need it in loose merge mode; replaces the former $exclude
1474
        ? {}
1475
        : { map { ( $_->[0], 1 ); } ( @record_from, @record_to ) };
1470
    foreach my $marcrecord(@reccache){
1476
    foreach my $marcrecord(@reccache){
1471
        my $update = 0;
1477
        my $update = 0;
1472
        foreach my $tagfield (@$tags_using_authtype){
1478
        foreach my $tagfield (@$tags_using_authtype){
Lines 1485-1501 sub merge { Link Here
1485
                        $field->indicator(2),
1491
                        $field->indicator(2),
1486
                        "9" => $mergeto,
1492
                        "9" => $mergeto,
1487
                    );
1493
                    );
1488
		my $exclude='9';
1489
                foreach my $subfield (grep {$_->[0] ne '9'} @record_to) {
1494
                foreach my $subfield (grep {$_->[0] ne '9'} @record_to) {
1490
                    $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
1495
                    $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
1491
		    $exclude.= $subfield->[0];
1492
                }
1496
                }
1493
		$exclude='['.$exclude.']';
1497
                if( !$overwrite ) {
1494
#		add subfields in $field not included in @record_to
1498
                    # add subfields back in loose mode, check skip_subfields
1495
        my @restore= $overwrite ? () : grep {$_->[0]!~/$exclude/} $field->subfields();
1499
                    foreach my $subfield ( $field->subfields ) {
1496
                foreach my $subfield (@restore) {
1500
                        next if $skip_subfields->{ $subfield->[0] };
1497
                   $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
1501
                        $field_to->add_subfields( $subfield->[0], $subfield->[1] );
1498
		}
1502
                    }
1503
                }
1499
            if( $tags_new ) {
1504
            if( $tags_new ) {
1500
                $marcrecord->delete_field( $field );
1505
                $marcrecord->delete_field( $field );
1501
                append_fields_ordered( $marcrecord, $field_to );
1506
                append_fields_ordered( $marcrecord, $field_to );
(-)a/t/db_dependent/Authorities/Merge.t (-2 / +6 lines)
Lines 135-141 subtest 'Test merge A1 to B1 (changing authtype)' => sub { Link Here
135
# Tests were aimed for bug 9988, moved to 17909 in adjusted form
135
# Tests were aimed for bug 9988, moved to 17909 in adjusted form
136
# Would not encourage this type of merge, but we should test what we offer
136
# Would not encourage this type of merge, but we should test what we offer
137
# The merge routine still needs the fixes on bug 17913
137
# The merge routine still needs the fixes on bug 17913
138
    plan tests => 12;
138
    plan tests => 13;
139
139
140
    # create two auth recs of different type
140
    # create two auth recs of different type
141
    my $auth1 = MARC::Record->new;
141
    my $auth1 = MARC::Record->new;
Lines 189-194 subtest 'Test merge A1 to B1 (changing authtype)' => sub { Link Here
189
    is( $newbiblio->subfield( '112', 'c' ),
189
    is( $newbiblio->subfield( '112', 'c' ),
190
        $auth2->subfield( '112', 'c' ), 'Check new 112c' );
190
        $auth2->subfield( '112', 'c' ), 'Check new 112c' );
191
191
192
    # Check 112b; this subfield was cleared when moving from 109 to 112
193
    # Note that this fix only applies to the current loose mode only
194
    is( $newbiblio->subfield( '112', 'b' ), undef,
195
        'Merge respects a cleared subfield in loose mode' );
196
192
    # Check the original 612
197
    # Check the original 612
193
    is( ( $newbiblio->field('612') )[0]->subfield( 'a' ),
198
    is( ( $newbiblio->field('612') )[0]->subfield( 'a' ),
194
        $oldbiblio->subfield( '612', 'a' ), 'Check untouched 612a' );
199
        $oldbiblio->subfield( '612', 'a' ), 'Check untouched 612a' );
195
- 

Return to bug 17913