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

--- Comment #135 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 209813
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209813&action=edit
Bug 42383: (QA follow-up) Make checkin follow-up actions atomic

Koha::Checkin->confirm_hold makes several writes: ModReserveAffect sets
the hold aside, then a transfer is requested and sent, and the checkin
is linked to it. They are not done in a transaction, so an error while
creating or sending the transfer leaves the hold in transit with no
transfer.

This patch addresses point 2 of comment #77 by wrapping the writes of
confirm_hold in a transaction. The other checkin actions writing more
than once are wrapped the same way:

- cancel_hold: cancels the hold and unlinks it from the checkin
- confirm_transfer: requests the transfer, links it and sends it
- cancel_transfer: cancels the transfer, reverts an in transit recall
  and unlinks the transfer from the checkin
- confirm_recall: Koha::Recall->start_transfer updates the recall and
  creates the transfer, set_waiting updates the recall and the item
- replace_wrong_transfer: replaces the transfer and links the new one

confirm_transfer now checks its parameters before starting the
transaction. The behaviour is unchanged.

Test plan:
1. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/Checkin.t
=> FAIL: When sending the transfer fails, the hold is left in transit
   and a transfer is created
2. Apply this patch
3. Run:
  k$ prove t/db_dependent/Koha/Checkin.t \
           t/db_dependent/api/v1/checkins.t
=> SUCCESS: Tests pass!
4. Sign off :-D

Assisted-by: Opus 5.5 (Anthropic)

-- 
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