Lines 1404-1409
sub merge {
Link Here
|
1404 |
|
1404 |
|
1405 |
my @record_to; |
1405 |
my @record_to; |
1406 |
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to); |
1406 |
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to); |
|
|
1407 |
# Exceptional: If MARCto and authtypeto exist but $auth_tag_to_report_to |
1408 |
# is empty, make sure that $9 and $a remain (instead of clearing the |
1409 |
# reference) in order to allow for data recovery. |
1410 |
# Note: We need $a too, since a single $9 does not pass ModBiblio. |
1411 |
if( $MARCto && $authtypeto && !@record_to ) { |
1412 |
push @record_to, [ 'a', ' ' ]; # do not remove the space |
1413 |
} |
1414 |
|
1407 |
my @record_from; |
1415 |
my @record_from; |
1408 |
if( !$authfrom && $MARCfrom && $MARCfrom->field('1..','2..') ) { |
1416 |
if( !$authfrom && $MARCfrom && $MARCfrom->field('1..','2..') ) { |
1409 |
# postponed merge, authfrom was deleted and MARCfrom only contains the old reporting tag (and possibly a 100 for UNIMARC) |
1417 |
# postponed merge, authfrom was deleted and MARCfrom only contains the old reporting tag (and possibly a 100 for UNIMARC) |
Lines 1418-1424
sub merge {
Link Here
|
1418 |
# For a deleted authority record, we scan all auth controlled fields |
1426 |
# For a deleted authority record, we scan all auth controlled fields |
1419 |
my $dbh = C4::Context->dbh; |
1427 |
my $dbh = C4::Context->dbh; |
1420 |
my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; |
1428 |
my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; |
1421 |
my $tags_using_authtype = $authtypefrom ? $dbh->selectcol_arrayref( $sql, undef, ( $authtypefrom->authtypecode )) : $dbh->selectcol_arrayref( "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode IS NOT NULL AND authtypecode<>''" ); |
1429 |
my $tags_using_authtype = $authtypefrom && $authtypefrom->authtypecode ? $dbh->selectcol_arrayref( $sql, undef, ( $authtypefrom->authtypecode )) : $dbh->selectcol_arrayref( "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode IS NOT NULL AND authtypecode<>''" ); |
1422 |
my $tags_new; |
1430 |
my $tags_new; |
1423 |
if( $authtypeto && ( !$authtypefrom || $authtypeto->authtypecode ne $authtypefrom->authtypecode )) { |
1431 |
if( $authtypeto && ( !$authtypefrom || $authtypeto->authtypecode ne $authtypefrom->authtypecode )) { |
1424 |
$tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); |
1432 |
$tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); |
Lines 1454-1460
sub merge {
Link Here
|
1454 |
$update = 1; |
1462 |
$update = 1; |
1455 |
next; |
1463 |
next; |
1456 |
} |
1464 |
} |
1457 |
my $newtag = $tags_new |
1465 |
my $newtag = $tags_new && @$tags_new |
1458 |
? _merge_newtag( $tag, $tags_new ) |
1466 |
? _merge_newtag( $tag, $tags_new ) |
1459 |
: $tag; |
1467 |
: $tag; |
1460 |
my $field_to = MARC::Field->new( |
1468 |
my $field_to = MARC::Field->new( |
Lines 1473-1479
sub merge {
Link Here
|
1473 |
$field_to->add_subfields( $subfield->[0], $subfield->[1] ); |
1481 |
$field_to->add_subfields( $subfield->[0], $subfield->[1] ); |
1474 |
} |
1482 |
} |
1475 |
} |
1483 |
} |
1476 |
if ($tags_new) { |
1484 |
if ($tags_new && @$tags_new) { |
1477 |
$marcrecord->delete_field($field); |
1485 |
$marcrecord->delete_field($field); |
1478 |
append_fields_ordered( $marcrecord, $field_to ); |
1486 |
append_fields_ordered( $marcrecord, $field_to ); |
1479 |
} else { |
1487 |
} else { |