Bug 30860: Cache CanItemBeReserved return value
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 22 Mar 2023 15:30:31 +0000 (16:30 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 23 Jun 2023 13:01:07 +0000 (10:01 -0300)
commit45852c950e8a7a2a5611d818790192dab76c1370
tree29fe5295c81d718b524f84f8a23cbe9a84e38cb1
parent79f8e148af7f7f84ccf43334e73e14f919157edd
Bug 30860: Cache CanItemBeReserved return value

This patch caches the return value of CanItemBeReserved that could
be then returned *on
demand*
We don't want to introduce side-effects hard to catch from this simple
change, so let's return the cache value only from the 2 scripts we are
dealing with.

This patch requests all item values from CanBookBeReserved on request.pl

Before this we either:
- Looped every item to find out that book could not be reserved
- Looped until we found an item that could be reserved, then looped all items to get statuses

In the worst case we avoid double processing a single item, in the best case we avoid double
processing all items (if only last on record is holdable)

To test:
1 - Find a record in staff client with several items
2 - Set AllowHoldsOnDamagedItems  to 'Dont allow'
3 - Add a damaged item to record
4 - Set a hold rule to only allow holds form homebranch and ensure record has items from other branches
5 - Setup things to prevent more items from being held
6 - Attempt hold for patron
7 - Note item statuses
8 - Apply patch
9 - Confirm statuses are as they were before

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
C4/Reserves.pm
opac/opac-reserve.pl
reserve/request.pl