From 16530f09687f48cb621c1a1dfc1559fc35979d51 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 21 May 2020 18:23:01 -0300 Subject: [PATCH] Bug 25570: Paginate results by default in objects->search This patch makes the helper paginate the resultsif no pagination parameters are passed. Page number defaults to 1, and the page size to the RESTdefaultPageSize syspref value. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t => FAIL: Pagination is not enforced by default 3. Apply this patch 4. Repeat 2 => SUCCESS: Results are paginated 5. Sign off :-D Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit 451ae76431d3d580494f917ed397f259cd96a876) Signed-off-by: Lucas Gass --- Koha/REST/Plugin/Objects.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm index f4e8be227f..c743e9da17 100644 --- a/Koha/REST/Plugin/Objects.pm +++ b/Koha/REST/Plugin/Objects.pm @@ -65,6 +65,10 @@ sub register { } ); + # If no pagination parameters are passed, default + $reserved_params->{_per_page} //= C4::Context->preference('RESTdefaultPageSize'); + $reserved_params->{_page} //= 1; + # Merge pagination into query attributes $c->dbic_merge_pagination( { -- 2.39.5