This patch starts improving export.pl by adding warnings, skipping invalid 
records, and not trying to access fields which don't exist.
---
 tools/export.pl |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/export.pl b/tools/export.pl
index b0cf6be..5f0a00a 100755
--- a/tools/export.pl
+++ b/tools/export.pl
@@ -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);
                 }
-- 
1.5.4.3

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to