From bab0ec16c131fc45eee11ad9a7f8697139cf9747 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 24 Jan 2017 14:53:33 +0100 Subject: [PATCH] Bug 16018: [Follow-up] Code cleaning Content-Type: text/plain; charset=utf-8 It is not useful to postpone a merge to the cron job here, since the old authority record is deleted. (Note that bug 9988 will address this subject too.) Removing the call to C4::ImportBatch::SetImportRecordStatus: Since $recordid2 is not an import_record_id, this is useless and potentially wrong. Removed the if statement for @errors, since it is not used at this point; putting the result of a comparison into $error is not useful either. Note: there is a lot of code in merge.pl around breeding that is actually unused. Template tools/manage-marc-import.tt contains two unused blocks final_match_link and match_link that contain a (unreachable) call to authorities/merge.pl with parameters: mergereference=breeding&authid=[% record_lis.match_id %]&authid=[% record_lis.import_record_id %] It seems that this would show the records correctly, but would not merge them correctly since that code expects two authority records. Leaving the signoff of Mehdi since he essentially tested the merge call. Test plan: See first patch. Signed-off-by: mehdi Signed-off-by: Marcel de Rooy Tested merging PERSO_NAME to PERSO_NAME and PERSO_NAME to CORPO_NAME. --- authorities/merge.pl | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/authorities/merge.pl b/authorities/merge.pl index 60bc6db..bef1bc5 100755 --- a/authorities/merge.pl +++ b/authorities/merge.pl @@ -61,29 +61,13 @@ if ($merge) { # This triggers a merge for the biblios attached to $recordid1 ModAuthority( $recordid1, $record, $typecode ); - # We still need a merge for biblios attached to $recordid2 - if( C4::Context->preference('dontmerge') ne '1' ) { - my $MARCfrom = GetAuthority( $recordid2 ); - &merge( $recordid2, $MARCfrom, $recordid1, $record ); - } else { - my $dbh = C4::Context->dbh; - my $sqlinsert = "INSERT INTO need_merge_authorities (authid, done) VALUES (?,?)"; - $dbh->do( $sqlinsert, undef, ( $recordid1, 0 ) ); - } + # Now merge for biblios attached to $recordid2 + # We ignore dontpref now, since recordid2 is deleted + my $MARCfrom = GetAuthority( $recordid2 ); + &merge( $recordid2, $MARCfrom, $recordid1, $record ); # Deleting the other record - if ( scalar(@errors) == 0 ) { - - my $error; - if ($input->param('mergereference') eq 'breeding') { - require C4::ImportBatch; - C4::ImportBatch::SetImportRecordStatus( $recordid2, 'imported' ); - } else { - C4::AuthoritiesMarc::merge( $recordid2, GetAuthority($recordid2), $recordid1, $record ); - $error = (DelAuthority($recordid2) == 0); - } - push @errors, $error if ($error); - } + DelAuthority( $recordid2 ); # Parameters $template->param( -- 2.1.4