merge_authority : Bug fixing
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 15 Oct 2008 19:36:06 +0000 (21:36 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Mon, 24 Nov 2008 17:07:59 +0000 (18:07 +0100)
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
misc/migration_tools/merge_authority.pl

index 6345c9d..b5e64f6 100755 (executable)
@@ -27,7 +27,7 @@ GetOptions(
     'b' => \$batch, 
 );
 
-if ($version || ($mergefrom eq '')) {
+if ($version || ($mergefrom eq '' && !$batch)) {
     print <<EOF
 Script to merge an authority into another
 parameters :
@@ -49,7 +49,6 @@ die;
 }#/'
 
 my $dbh = C4::Context->dbh;
-# my @subf = $subfields =~ /(##\d\d\d##.)/g;
 
 $|=1; # flushes output
 my $authfrom = GetAuthority($mergefrom);
@@ -58,7 +57,7 @@ my $authto = GetAuthority($mergeto);
 my $authtypecodefrom = GetAuthTypeCode($mergefrom);
 my $authtypecodeto = GetAuthTypeCode($mergeto);
 
-unless ($noconfirm) {
+unless ($noconfirm || $batch) {
     print "************\n";
     print "You will merge authority : $mergefrom ($authtypecodefrom)\n".$authfrom->as_formatted;
     print "\n*************\n";
@@ -85,7 +84,8 @@ if ($batch) {
     if ($authid =~ /\.authid$/) {
       $authid =~ s/\.authid$//;
       print "managing $authid\n" if $verbose;
-      my $MARCauth = GetAuthority($authid);
+      my $MARCauth = GetAuthority($authid) ;
+      next unless ($MARCauth);
       merge($authid,$MARCauth,$authid,$MARCauth) if ($MARCauth);
       unlink $cgidir.'/localfile/modified_authorities/'.$authid.'.authid';
     }