]> git.koha-community.org Git - koha.git/commit
Bug 35053: Make sure request is checked as an item-level request if item_id passed
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 17 Oct 2023 12:07:28 +0000 (09:07 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Wed, 25 Oct 2023 21:46:43 +0000 (11:46 -1000)
commit8a945f3e811cfb39c0a0212554b1adfca2b041bb
tree40263142b5359eae2e4a765c3d8dff20d75a7aba
parent6de7575caee576335b2a764a117b70cc1171c472
Bug 35053: Make sure request is checked as an item-level request if item_id passed

This patch makes the validation code have the `$item` variable defined
when checking holdability, in the case both `item_id` and `biblio_id`
params are passed.

Otherwise, if the requested item is not holdable, but a biblio-level
hold *could* be placed, the item-level hold is placed.

This is highlighted by the regression tests.

To test:
1. Apply the regression tests patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/holds.t
=> FAIL: Tests don't pass. A request that should be rejected is allowed
because biblio-level hold is allowed.
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass! Item-level rules are checked and thus the
request rejected (code 403)
5. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 82e0edd87606ce05511b33ddeeea10f2b9e68f3d)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/REST/V1/Holds.pm