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 :
   <ListRecords/>
=> With patch you get a response with error code :
   <error code="noRecordsMatch">No records match the given criteria</error>
- Check a good query returns still results
- Same test with ListIdentifiers verb

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Fridolin Somers 2015-08-25 11:33:04 +02:00 committed by Tomas Cohen Arazi
parent abd71d017e
commit 64992a05ce
1 changed files with 16 additions and 0 deletions

View File

@ -411,6 +411,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;
}
@ -586,6 +594,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;
}