Bug 6001 : batchRebuildBiblioTables.pl doesn't crash anymore when GetMarcBiblio fails...
authorMatthias Meusburger <matthias.meusburger@biblibre.com>
Thu, 1 Apr 2010 14:07:25 +0000 (16:07 +0200)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 28 Apr 2011 20:56:57 +0000 (08:56 +1200)
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

misc/batchRebuildBiblioTables.pl

index b15a91a..ae4f54e 100755 (executable)
@@ -58,9 +58,14 @@ my $sth = $dbh->prepare("SELECT biblionumber FROM biblio");
 $sth->execute;
 # my ($biblionumbermax) =  $sth->fetchrow;
 # warn "$biblionumbermax <<==";
+my @errors;
 while (my ($biblionumber)= $sth->fetchrow) {
     #now, parse the record, extract the item fields, and store them in somewhere else.
     my $record = GetMarcBiblio($biblionumber);
+    if (not defined $record) {
+       push @errors, $biblionumber;
+       next;
+    }
     my @fields = $record->field($tagfield);
     my @items;
     my $nbitems=0;
@@ -82,6 +87,9 @@ while (my ($biblionumber)= $sth->fetchrow) {
 # $dbh->do("unlock tables");
 my $timeneeded = time() - $starttime;
 print "$i MARC record done in $timeneeded seconds\n";
+if (scalar(@errors) > 0) {
+    print "Some biblionumber could not be processed though: ", join(" ", @errors);
+}
 
 # modified NEWmodbiblio to jump the MARC part of the biblio modif
 # highly faster