Bug 34316

Summary: account->add_credit does not rethrow exception
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Architecture, internals, and plumbingAssignee: Marcel de Rooy <m.de.rooy>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, lucas, martin.renvoize
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.03,22.11.09,22.05.16
Circulation function:
Bug Depends on:    
Bug Blocks: 33608    
Attachments: Bug 34316: Add_credit should rethrow an exception correctly

Description Marcel de Rooy 2023-07-20 07:28:52 UTC
Found while debugging 33608 on a new failure in Items.t.
It was a FK constraint on credit_id which was very misleading.
Cause is an exception that was not rethrown in Accounts coming from a wrong statistic type and revealed now by new code in UpdateStats/Statistic.pm.
Comment 1 Marcel de Rooy 2023-07-20 08:00:20 UTC
Created attachment 153697 [details] [review]
Bug 34316: Add_credit should rethrow an exception correctly

Found while running Items.t on top of 33608.
Another exception was thrown but not rethrown.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 2 Marcel de Rooy 2023-07-20 08:16:46 UTC
(In reply to Marcel de Rooy from comment #0)
> Found while debugging 33608 on a new failure in Items.t.
> It was a FK constraint on credit_id which was very misleading.
> Cause is an exception that was not rethrown in Accounts coming from a wrong
> statistic type and revealed now by new code in UpdateStats/Statistic.pm.

Actually, there is still another thing ;)
Related to new code that looks at value instead of amount.
So 33608 needs a correction too.
Rethrowing the exception should go here on its own.
Comment 3 Marcel de Rooy 2023-07-20 08:17:18 UTC
Moving to PQA. Trivial and needed.
Comment 4 Martin Renvoize (ashimema) 2023-07-20 09:23:42 UTC
Looks good to me
Comment 5 Tomás Cohen Arazi (tcohen) 2023-07-20 14:01:04 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 6 Fridolin Somers 2023-08-04 01:51:17 UTC
Pushed to 23.05.x for 23.05.03
Comment 7 Pedro Amorim 2023-08-18 10:53:48 UTC
Nice work everyone!

Pushed to 22.11.x for next release
Comment 8 Lucas Gass (lukeg) 2023-09-13 21:02:27 UTC
Backported to 22.05.x for upcoming 22.05.16