Bug 31369

Summary: Koha::Recalls->add_recall should validate there's a related checkout
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low    
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 29734    
Bug Blocks:    

Description Tomás Cohen Arazi 2022-08-16 12:50:50 UTC
I haven't really tried, but the code cleary relies on an $recall->checkout returning a Koha::Checkout object... Which shouldn't be taken for granted. The way it is constructed is fragile and makes the controller need to perform all the checks, that really belong here. It should probably throw an exception as well. Right now the code can generate a recall object (store it on the DB) and then explode because of the lack of the checkout. This also points to the need of a transaction.