Koha-clms/t/db_dependent/Koha/Checkouts
Tomás Cohen Arazi 4189d42ee6
Bug 42391: (follow-up) Restore DB exception warnings in Object::store
Bug 42391 removed the warn from Koha::Object::store when it moved
exception translation to the exception_action hook. This lost useful
debugging information from the Plack error logs.

This patch restores the warning by adding a try/catch in store() that
stringifies and warns the exception before rethrowing. The warning now
contains the translated Koha exception message (e.g. 'Broken FK
constraint') rather than the raw DBI error, since translation happens
before the exception reaches store().

Note: delete() does not warn. Ideally the logging would live in the
ExceptionMapper itself (via an injected logger), covering all code paths
uniformly. That is a larger refactor tracked separately.

Tests that assert on these warnings are updated to match the new
message format.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
   k$ prove t/db_dependent/Koha/Object.t \
       t/db_dependent/Koha/Objects.t \
       t/db_dependent/Koha/Schema/ExceptionMapper.t \
       t/db_dependent/Koha/Item.t \
       t/db_dependent/Koha/Suggestions.t \
       t/db_dependent/Koha/Account.t \
       t/db_dependent/Koha/ApiKey.t \
       t/db_dependent/Koha/Checkouts/ReturnClaim.t \
       t/db_dependent/Circulation/MarkIssueReturned.t \
       t/db_dependent/Suggestions.t \
       t/db_dependent/Biblio.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-07-21 15:40:23 +00:00
..
Renewal.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
ReturnClaim.t Bug 42391: (follow-up) Restore DB exception warnings in Object::store 2026-07-21 15:40:23 +00:00