From b3b10df1e480f16e74abc8eef3ac568d84005c4b Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 25 Aug 2015 11:33:04 +0200 Subject: [PATCH] Bug 14721: OAI-PMH must return error when no results When getting records from OAI-PMH, an error must be returned if there is no results. See : http://www.openarchives.org/OAI/openarchivesprotocol.html#ErrorConditions Test plan : - Enable OAI webservice - Perform a query that will return no results. ie : /cgi-bin/koha/oai.pl?verb=ListRecords&metadataPrefix=marcxml&from=2099-12-30&until=2099-12-31 => Without patch you get a response with : => With patch you get a response with error code : No records match the given criteria - Check a good query returns still results - Same test with ListIdentifiers verb Signed-off-by: Mirko Tietgen Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 64992a05ce87af7bf595c8d6f0b9d528887a2e44) Signed-off-by: Chris Cormack (cherry picked from commit 3d8e059513db08f2070e33ea1562d7cdd915797c) Signed-off-by: Liz Rea --- opac/oai.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/opac/oai.pl b/opac/oai.pl index 40c143b145..eef15bb4d3 100755 --- a/opac/oai.pl +++ b/opac/oai.pl @@ -353,6 +353,14 @@ sub new { ) ); } + # Return error if no results + unless ($count) { + return HTTP::OAI::Response->new( + requestURL => $repository->self_url(), + errors => [ new HTTP::OAI::Error( code => 'noRecordsMatch' ) ], + ); + } + return $self; } @@ -516,6 +524,14 @@ sub new { ) ); } + # Return error if no results + unless ($count) { + return HTTP::OAI::Response->new( + requestURL => $repository->self_url(), + errors => [ new HTTP::OAI::Error( code => 'noRecordsMatch' ) ], + ); + } + return $self; } -- 2.39.5