https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42386

--- Comment #64 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 203523
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203523&action=edit
Bug 42386: (follow-up) Fix hold-availability regressions and reduce duplication

Koha::Patron->can_place_holds duplicated the exact same six patron
eligibility checks now implemented in Koha::Patron::Availability::Hold,
and Koha::REST::V1::Holds ran both in sequence on every hold placement.
can_place_holds is now a thin wrapper over Koha::Patron::Availability::Hold,
passing the already-fetched patron object through and preserving the
existing message/payload contract (debt_limit/hold_limit payloads).

Koha::Item::Availability::Hold's item_already_on_hold check had also
stopped respecting skip_patron_checks (the legacy ignore_hold_counts
semantics), which C4::Circulation's decreaseLoanHighHoldsControl=dynamic
logic and Koha::Hold's hold-move logic both rely on when checking whether
an item can fill a hold the patron already placed on it - both were newly
at risk of mis-blocking. Restored, while adding a distinct
skip_patron_count_checks flag so Koha::Biblio::Availability::Hold's
per-item loop (which still needs item_already_on_hold evaluated per item)
doesn't lose that check.

Finally, CanItemBeReserved's per-item display loops in reserve/request.pl
and opac-reserve.pl were newly re-running the full patron eligibility and
rule-based count checks for every single item on a record, where the old
CanItemBeReserved never did any patron-level checks at all. Added
skip_eligibility_checks (skip only the no-item-context gates, already
shown once at the page level) and an opt-in cache_counts flag (memoizing
the rule-based count queries per request, off by default so the test
suite and any caller that places holds mid-loop always sees a fresh
count), and wired both into the two affected loops.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
   k$ prove t/db_dependent/Koha/Patron/Availability/Hold.t \
       t/db_dependent/Koha/Item/Availability/Hold.t \
       t/db_dependent/Koha/Biblio/Availability/Hold.t \
       t/db_dependent/Reserves.t t/db_dependent/Holds.t \
       t/db_dependent/Reserves/MultiplePerRecord.t \
       t/db_dependent/ILSDI_Services.t \
       t/db_dependent/api/v1/holds.t t/db_dependent/api/v1/clubs_holds.t \
       t/db_dependent/Koha/Patron.t t/db_dependent/DecreaseLoanHighHolds.t
=> SUCCESS: All tests pass!
3. Sign off :-D

Signed-off-by: Martin Renvoize <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to