[Bug 44048] New: Koha::Account->add_debit swallows unexpected errors and returns undef
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44048 Bug ID: 44048 Summary: Koha::Account->add_debit swallows unexpected errors and returns undef Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Fines and fees Assignee: koha-bugs@lists.koha-community.org Reporter: babarjunaid1122@gmail.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- In Koha::Account->add_debit the catch block only handles Koha::Exceptions::Object::FKConstraint: a broken debit_type_code becomes UnrecognisedType, any other broken FK is rethrown. Every other error raised while the debit, its offset or its log are stored is swallowed, and add_debit returns undef as if it had run. Callers then carry on as if the charge was added: the transaction that should have been rolled back is committed without it, and nothing reports that a fine, a rental charge or a lost fee was never recorded. add_credit does this correctly: after its FK branch it rethrows ($_->rethrow). To see it: make Koha::Account::Line->store die (e.g. mock it in a test) and call add_debit: no exception, return value undef. Same code on main and 26.05. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44048 babar junaid <babarjunaid1122@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=41385 -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44048 --- Comment #1 from babar junaid <babarjunaid1122@gmail.com> --- Created attachment 211193 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211193&action=edit Bug 44048: Do not let add_debit swallow unexpected errors Bug 44048: Do not let add_debit swallow unexpected errors The catch block of Koha::Account->add_debit only handled FKConstraint exceptions. Any other error raised while storing the debit, its offset or its log was swallowed and add_debit returned undef, so the caller carried on as if the charge had been added and its transaction committed without it. Rethrow every error that is not the debit_type_code FK, as add_credit does. Test plan: 1. prove t/db_dependent/Koha/Account.t The new add_debit subtest (Koha::Account::Line->store mocked to die) fails without the patch: no exception, undef returned. 2. With the patch the whole file passes. Sponsored-by: Koha Solutions -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44048 babar junaid <babarjunaid1122@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |babarjunaid1122@gmail.com |ity.org | Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org