From 13239b15a56822beef510feb7cd08bba8e51265d 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=utf8 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 Signed-off-by: Jonathan Druart Fix works for 3.18.x and 3.20.x 3.22 is not impacted Signed-off-by: Frédéric Demians --- opac/oai.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/opac/oai.pl b/opac/oai.pl index b8c63a900d..594149fac1 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.39.5