dealing with empty XML : return an empty string, and not an empty MARC::Record
authorPaul POULAIN <paul@koha-fr.org>
Wed, 31 Oct 2007 18:12:13 +0000 (13:12 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 1 Nov 2007 00:39:21 +0000 (19:39 -0500)
(Useful for zebraque_start)

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Biblio.pm

index b7b559d..6c9fe4e 100644 (file)
@@ -1611,11 +1611,14 @@ sub GetMarcBiblio {
      $marcxml =~ s/\x0c//g;  
 #   warn $marcxml;
     my $record = MARC::Record->new();
-     
-      $record = eval {MARC::Record::new_from_xml( $marcxml, "utf8",C4::Context->preference('marcflavour'))} if ($marcxml);
-     if ($@) {warn $@;}
+    if ($marcxml) {
+        $record = eval {MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour'))};
+        if ($@) {warn $@;}
 #      $record = MARC::Record::new_from_usmarc( $marc) if $marc;
-    return $record;
+        return $record;
+    } else {
+        return undef;
+    }
 }
 
 =head2 GetXmlBiblio