Lines 1443-1448
sub merge {
Link Here
|
1443 |
|
1443 |
|
1444 |
my @record_to; |
1444 |
my @record_to; |
1445 |
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to); |
1445 |
@record_to = $MARCto->field($auth_tag_to_report_to)->subfields() if $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to); |
|
|
1446 |
# Exceptional: If MARCto and authtypeto exist but $auth_tag_to_report_to |
1447 |
# is empty, make sure that $9 and $a remain (instead of clearing the |
1448 |
# reference) in order to allow for data recovery. |
1449 |
# Note: We need $a too, since a single $9 does not pass ModBiblio. |
1450 |
if( $MARCto && $authtypeto && !@record_to ) { |
1451 |
push @record_to, [ 'a', ' ' ]; # do not remove the space |
1452 |
} |
1453 |
|
1446 |
my @record_from; |
1454 |
my @record_from; |
1447 |
if( !$authfrom && $MARCfrom && $MARCfrom->field('1..','2..') ) { |
1455 |
if( !$authfrom && $MARCfrom && $MARCfrom->field('1..','2..') ) { |
1448 |
# postponed merge, authfrom was deleted and MARCfrom only contains the old reporting tag (and possibly a 100 for UNIMARC) |
1456 |
# postponed merge, authfrom was deleted and MARCfrom only contains the old reporting tag (and possibly a 100 for UNIMARC) |
Lines 1457-1463
sub merge {
Link Here
|
1457 |
# For a deleted authority record, we scan all auth controlled fields |
1465 |
# For a deleted authority record, we scan all auth controlled fields |
1458 |
my $dbh = C4::Context->dbh; |
1466 |
my $dbh = C4::Context->dbh; |
1459 |
my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; |
1467 |
my $sql = "SELECT DISTINCT tagfield FROM marc_subfield_structure WHERE authtypecode=?"; |
1460 |
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<>''" ); |
1468 |
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<>''" ); |
1461 |
my $tags_new; |
1469 |
my $tags_new; |
1462 |
if( $authtypeto && ( !$authtypefrom || $authtypeto->authtypecode ne $authtypefrom->authtypecode )) { |
1470 |
if( $authtypeto && ( !$authtypefrom || $authtypeto->authtypecode ne $authtypefrom->authtypecode )) { |
1463 |
$tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); |
1471 |
$tags_new = $dbh->selectcol_arrayref( $sql, undef, ( $authtypeto->authtypecode )); |
Lines 1493-1499
sub merge {
Link Here
|
1493 |
$update = 1; |
1501 |
$update = 1; |
1494 |
next; |
1502 |
next; |
1495 |
} |
1503 |
} |
1496 |
my $newtag = $tags_new |
1504 |
my $newtag = $tags_new && @$tags_new |
1497 |
? _merge_newtag( $tag, $tags_new ) |
1505 |
? _merge_newtag( $tag, $tags_new ) |
1498 |
: $tag; |
1506 |
: $tag; |
1499 |
my $field_to = MARC::Field->new( |
1507 |
my $field_to = MARC::Field->new( |
Lines 1512-1518
sub merge {
Link Here
|
1512 |
$field_to->add_subfields( $subfield->[0], $subfield->[1] ); |
1520 |
$field_to->add_subfields( $subfield->[0], $subfield->[1] ); |
1513 |
} |
1521 |
} |
1514 |
} |
1522 |
} |
1515 |
if ($tags_new) { |
1523 |
if ($tags_new && @$tags_new) { |
1516 |
$marcrecord->delete_field($field); |
1524 |
$marcrecord->delete_field($field); |
1517 |
append_fields_ordered( $marcrecord, $field_to ); |
1525 |
append_fields_ordered( $marcrecord, $field_to ); |
1518 |
} else { |
1526 |
} else { |