]> git.koha-community.org Git - koha.git/commit
Bug 35129: Return 400 if _per_page=0 passed
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 18 Mar 2024 15:49:20 +0000 (12:49 -0300)
committerLucas Gass <lucas@bywatersolutions.com>
Tue, 28 May 2024 16:47:54 +0000 (16:47 +0000)
commit25724e8f3e66a832cb81cb86c49d17f64a1ec33c
tree93f0c2bbc9c89ce6670116e1d07b2b9ed4114a2e
parent92053898a1086742926e5c470986aa09c990606e
Bug 35129: Return 400 if _per_page=0 passed

This patch adds a safe guard for when consumers pass _per_page=0 to
endpoints. This condition is checked for on a centralized place and
avoid reaching the controller in such scenarios that would provoke a
division by zero exception.

To test:
1. Apply the regression tests patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/pagination.t
=> FAIL: We expect a 400, but get a 500 instead
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass! No more explosions for this!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 308bb0830cfe69116e442bad4cd206dd402244be)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit b1e9ef93f2181cc63537be6d09027491885dc303)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Koha/REST/V1/Auth.pm