From 4eb800731e59ba6b24ef8c8f533b1a38e5f7ae32 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 1 Sep 2015 09:46:35 +0200 Subject: [PATCH] Bug 14363: OAI-PMH: Handle records without marcxml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test plan: 1/ git checkout 3.18.x 2/ GET http://OPAC/cgi-bin/koha/oai.pl?verb=ListRecords&metadataPrefix=marcxml 3/ Take the first biblionumber from the results ($biblionumber) 4/ mysql> update biblioitems set marcxml=null where biblionumber=$biblionumber 5/ Repeat step 2 => XML error 6/ Apply patch 7/ Repeat step 2 => no errors Signed-off-by: Frédéric Demians Works on 3.20.x --- opac/oai.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/opac/oai.pl b/opac/oai.pl index b8c63a9..594149f 100755 --- a/opac/oai.pl +++ b/opac/oai.pl @@ -225,7 +225,15 @@ sub new { } my $parser = XML::LibXML->new(); - my $record_dom = $parser->parse_string( $marcxml ); + my $record_dom; + eval { + $record_dom = $parser->parse_string( $marcxml ); + }; + if ($@) { + warn "OAI-PMH: No marcxml for record " . $args{identifier}; + return $self; + } + my $format = $args{metadataPrefix}; if ( $format ne 'marcxml' ) { my %args = ( -- 2.6.2