eval() on getAuthority & getBiblio to avoid a script failure
authortipaul <tipaul>
Wed, 1 Aug 2007 09:20:03 +0000 (09:20 +0000)
committertipaul <tipaul>
Wed, 1 Aug 2007 09:20:03 +0000 (09:20 +0000)
misc/migration_tools/rebuild_zebra.pl

index 9c33092..b9b7946 100755 (executable)
@@ -290,7 +290,15 @@ rank:rank-1
         $sth->execute();
         my $i=0;
         while (my ($authid) = $sth->fetchrow) {
-            my $record = GetAuthority($authid);
+            my $record;
+            eval {
+                $record = GetAuthority($authid);
+            };
+            if($@){
+                print "  There was some pb getting authority : ".$authid."\n";
+            next;
+            }
+
             print ".";
             print "\r$i" unless ($i++ %100);
             # remove leader length, that could be wrong, it will be calculated automatically by as_usmarc
@@ -481,11 +489,18 @@ rank:rank-1
         open(OUT,">:utf8 ","$directory/biblios/export") or die $!;
         my $dbh=C4::Context->dbh;
         my $sth;
-        $sth=$dbh->prepare("select biblionumber from biblioitems where biblionumber >54000 order by biblionumber $limit");
+        $sth=$dbh->prepare("select biblionumber from biblioitems order by biblionumber $limit");
         $sth->execute();
         my $i=0;
         while (my ($biblionumber) = $sth->fetchrow) {
-            my $record = GetMarcBiblio($biblionumber);
+            my $record;
+            eval {
+                $record = GetMarcBiblio($biblionumber);
+            };
+            if($@){
+                print "  There was some pb getting biblio : #".$biblionumber."\n";
+            next;
+            }
 #             warn $record->as_formatted;
 # die if $record->subfield('090','9') eq 11;
     #         print $record;