bypass corrupt bibs when linking headings
authorGalen Charlton <galen.charlton@liblime.com>
Mon, 16 Jun 2008 13:45:55 +0000 (08:45 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Mon, 16 Jun 2008 15:24:28 +0000 (10:24 -0500)
During link_bibs_to_authorities.pl run, a bib was
observed that had both biblioitems.marc and biblioitems.marcxml
set to blank or NULL.  Added check to verify that a
defined value is returned from GetMarcBiblio(); may follow
up with additional patches once it's determined how
the corrupt bib came to be loaded.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>

misc/link_bibs_to_authorities.pl

index 0ef713a..1cb0483 100755 (executable)
@@ -32,6 +32,7 @@ if (not $result or $want_help) {
 
 my $num_bibs_processed = 0;
 my $num_bibs_modified = 0;
+my $num_bad_bibs = 0;
 my $dbh = C4::Context->dbh;
 $dbh->{AutoCommit} = 0;
 process_bibs();
@@ -62,6 +63,7 @@ Bib authority heading linking report
 ------------------------------------
 Number of bibs checked:       $num_bibs_processed
 Number of bibs modified:      $num_bibs_modified
+Number of bibs with errors:   $num_bad_bibs
 _SUMMARY_
 }
 
@@ -69,6 +71,12 @@ sub process_bib {
     my $biblionumber = shift;
 
     my $bib = GetMarcBiblio($biblionumber);
+    unless (defined $bib) {
+        print "\nCould not retrieve bib $biblionumber from the database - record is corrupt.\n";
+        $num_bad_bibs++;
+        return;
+    }
+
     my $headings_changed = LinkBibHeadingsToAuthorities($bib);
 
     if ($headings_changed) {