From abe9abf47083d26300a4e09100ba362e6facf6dc Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 15 Nov 2021 09:52:15 -0300 Subject: [PATCH] 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 Signed-off-by: David Nind JD amended patch - ) unless scalar @{$sets} > 0; + ) unless @$sets; Signed-off-by: Jonathan Druart Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall --- Koha/OAI/Server/ListSets.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Koha/OAI/Server/ListSets.pm b/Koha/OAI/Server/ListSets.pm index 6fc245daeb..a74dda1bad 100644 --- a/Koha/OAI/Server/ListSets.pm +++ b/Koha/OAI/Server/ListSets.pm @@ -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++; -- 2.39.5