From ae48ff6729b4b36139ba53c6e49ee3c458186141 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 1 Dec 2017 12:29:48 +0100 Subject: [PATCH] Bug 18071: (QA follow-up) Add commit parameter, add warning Addressing points mentioned in comment12: [1] Commit parameter. [2] Warning if authid does not exist for -merge. Test plan: [1] Run update_authorities.pl -authid X -merge -ref Y -c where X does not exist in your db and Y does. Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- misc/maintenance/update_authorities.pl | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/misc/maintenance/update_authorities.pl b/misc/maintenance/update_authorities.pl index 2f2ebe9afe..9d3c50ff99 100755 --- a/misc/maintenance/update_authorities.pl +++ b/misc/maintenance/update_authorities.pl @@ -25,9 +25,10 @@ use Pod::Usage; use C4::AuthoritiesMarc qw/AddAuthority DelAuthority GetAuthority merge/; -my ( @authid, $delete, $help, $merge, $reference, $renumber, $verbose ); +my ( @authid, $commit, $delete, $help, $merge, $reference, $renumber, $verbose ); GetOptions( 'authid:s' => \@authid, + 'commit' => \$commit, 'delete' => \$delete, 'help' => \$help, 'merge' => \$merge, @@ -37,14 +38,17 @@ GetOptions( ); @authid = map { split /[,]/, $_; } @authid; -if( $delete ) { +if( $help ) { + pod2usage(1); +} elsif( !$commit ) { + print "Please add -commit parameter\n"; + exit; +} elsif( $delete ) { delete_auth( \@authid ); } elsif( $merge ) { merge_auth( \@authid, $reference ); } elsif( $renumber ) { renumber( \@authid ); -} elsif( $help ) { - pod2usage(1); } else { pod2usage(1); } @@ -71,7 +75,11 @@ sub merge_auth { my $marc; foreach my $authid ( uniq(@$auths) ) { next if $authid == $reference; - $marc = GetAuthority($authid) || next; + $marc = GetAuthority($authid); + if( !$marc ) { + print "Authority id $authid ignored, does not exist.\n"; + next; + } merge({ mergefrom => $authid, MARCfrom => $marc, mergeto => $reference, MARCto => $marc_ref, override_limit => 1 }); DelAuthority({ authid => $authid, skip_merge => 1 }); print "Record $authid merged into reference.\n" if $verbose; @@ -107,21 +115,23 @@ It also allows you to force a renumber, i.e. save the authid into field 001. =head1 SYNOPSIS -update_authorities.pl -authid 1,2,3 -delete +update_authorities.pl -c -authid 1,2,3 -delete -update_authorities.pl -authid 1 -authid 2 -authid 3 -delete +update_authorities.pl -c -authid 1 -authid 2 -authid 3 -delete -update_authorities.pl -authid 1,2 -merge -reference 3 +update_authorities.pl -c -authid 1,2 -merge -reference 3 -update_authorities.pl -merge -reference 4 +update_authorities.pl -c -merge -reference 4 -update_authorities.pl -authid 1,2,3 -renumber +update_authorities.pl -c -authid 1,2,3 -renumber =head1 OPTIONS authid: List authority numbers separated by commas or repeat the parameter. +commit: Needed to commit changes. + delete: Delete the listed authority numbers and remove its references from linked biblio records. -- 2.39.5