Bug 6076: acqui pdf error when marcxml wrong
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 8 Jul 2011 09:13:41 +0000 (11:13 +0200)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 6 Oct 2011 21:20:13 +0000 (10:20 +1300)
when marcxml is wrong the PDF is not generated. There is a Perl error
because
the biblio can't be retrieved.
This can be workarounded with a eval when decoding the marc

Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
acqui/basketgroup.pl

index 5dbae17..fbcad0f 100755 (executable)
@@ -251,10 +251,13 @@ sub printbasketgrouppdf{
                 push(@ba_orders, \@ba_order);
                 # Editor Number
                 my $en;
-                if (C4::Context->preference("marcflavour") eq 'UNIMARC') {
-                    $en = MARC::Record::new_from_xml($ord->{marcxml},'UTF-8')->subfield('345',"b");
-                } elsif (C4::Context->preference("marcflavour") eq 'MARC21') {
-                    $en = MARC::Record::new_from_xml($ord->{marcxml},'UTF-8')->subfield('037',"a");
+                my $marcrecord=eval{MARC::Record::new_from_xml( $ord->{marcxml},'UTF-8' )};
+                if ($marcrecord){
+                    if ( C4::Context->preference("marcflavour") eq 'UNIMARC' ) {
+                        $en = $marcrecord->subfield( '345', "b" );
+                    } elsif ( C4::Context->preference("marcflavour") eq 'MARC21' ) {
+                        $en = $marcrecord->subfield( '037', "a" );
+                    }
                 }
                 if($en){
                     push(@ba_order, $en);