Bug 29484: Make ListSets return noSetHierarchy when no sets defined

This simple patch makes our OAI-PMH server return the appropriate error
code when no sets are defined.

To test:
1. Apply the regression tests
2. Run:
   $ kshell
  k$ t/db_dependent/OAI/Server.t
=> FAIL: Tests fail. Boo!
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass! YAY!
5. Sign off :-D

Bonus: you can check with the tool mentioned on the bug report, that
the error is gone. No sets need to be defined.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: David Nind <david@davidnind.com>

JD amended patch
-    ) unless scalar @{$sets} > 0;
+    ) unless @$sets;

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2021-11-15 09:52:15 -03:00 committed by Kyle Hall
parent e32e9d49c5
commit abe9abf470
1 changed files with 11 additions and 0 deletions

View File

@ -34,6 +34,17 @@ sub new {
my $token = Koha::OAI::Server::ResumptionToken->new(%args);
my $sets = GetOAISets;
my $pos = 0;
return HTTP::OAI::Response->new(
requestURL => $repository->self_url(),
errors => [
HTTP::OAI::Error->new(
code => 'noSetHierarchy',
message => 'There are no OAI sets defined',
)
],
) unless @$sets;
foreach my $set (@$sets) {
if ($pos < $token->{cursor}) {
$pos++;