bug 1907 Partial fix: prevent bad records from truncating output.
authorChris Catalfo <ccatalfo@gmail.com>
Fri, 1 May 2009 23:34:43 +0000 (23:34 +0000)
committerGalen Charlton <galen.charlton@liblime.com>
Mon, 11 May 2009 13:03:17 +0000 (08:03 -0500)
This patch starts improving export.pl by adding warnings, skipping invalid records, and not trying to access fields which don't exist.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
tools/export.pl

index b0cf6be..5f0a00a 100755 (executable)
@@ -18,7 +18,7 @@
 
 
 use strict;
-
+use warnings;
 use C4::Auth;
 use C4::Output;  # contains gettemplate
 use C4::Biblio;  # GetMarcBiblio GetXmlBiblio
@@ -128,7 +128,7 @@ if ($op eq "export") {
     
     while (my ($biblionumber) = $sth->fetchrow) {
         my $record = GetMarcBiblio($biblionumber);
-
+        next if not defined $record;
         if ( $dont_export_items || $strip_nonlocal_items || $limit_ind_branch) {
             my ( $homebranchfield, $homebranchsubfield ) =
                 GetMarcFromKohaField( 'items.homebranch', '' );
@@ -145,6 +145,8 @@ if ($op eq "export") {
                 /^(\d*)(\w)?$/;
                 my $field = $1;
                 my $subfield = $2;
+                # skip if this record doesn't have this field
+                next if not defined $record->field($field);
                 if( $subfield ) {
                     $record->field($field)->delete_subfields($subfield);
                 }