Bug 34178: Cache ItemsAnyAvailableAndNotRestricted in memory and don't precalculate
authorNick Clemens <nick@bywatersolutions.com>
Fri, 30 Jun 2023 19:26:40 +0000 (19:26 +0000)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 25 Jul 2023 20:20:51 +0000 (10:20 -1000)
commit52ca4959554c854e0b3a11cc4bc3e8ef74fd1629
tree2497ab411022506a0e46e0e4c92dbe3e9cf5d51c
parent84cfa20a73c12681728b7c5d777135648e96ba95
Bug 34178: Cache ItemsAnyAvailableAndNotRestricted in memory and don't precalculate

There are several places in the code where we precalculate ItemsAnyAvailableAndNotRestricted to avoid
looping on this routine when calling IsAvailableForItemLevelRequest on a list of items form a biblio

The value of ItemsAnyAvailableAndNotRestricted is only used when there is a circulation rule for
'onshelfholds' with a value of '2' (If all unavailable)

Rather than calculate a value that may never be used, let's cache this value per request when we do
calculate it - and reuse the cached value

To test:
 1 - Apply patch
 2 - Set circulation rule 'On shelf holds allowed' as 'If all unavailable'
    make sure the rule applies to all of the items/patrons you test with
 3 - Find a record with two items that are available
 4 - Try to place a hold for a patron - not allowed
 5 - Check out one item to another patron
 6 - Attempt hold - still not allowed
 7 - Check out second item to another patron
 8 - Attempt hold - allowed!
 9 - Apply patch
10 - Cancel and replace hold - it is allowed!
11 - Check in one item, and cancel hold
12 - Place hold - not allowed!
13 - Check in second item
14 - Place hold - not allowed!
15 - prove -v t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
C4/Circulation.pm
C4/Reserves.pm
opac/opac-reserve.pl
reserve/request.pl