Bug 42030 - Add diff support to SUGGESTION action logs
Summary: Add diff support to SUGGESTION action logs
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Transaction logs (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 37940
  Show dependency treegraph
 
Reported: 2026-03-09 15:34 UTC by Martin Renvoize (ashimema)
Modified: 2026-03-09 21:18 UTC (History)
0 users

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: Unsponsored
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 42030: Populate diff column for suggestion CREATE/MODIFY/DELETE logs (5.32 KB, patch)
2026-03-09 21:18 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2026-03-09 15:34:34 UTC
The action logging for the SUGGESTION module (Koha/Suggestion.pm) currently logs CREATE and MODIFY actions without passing the $original parameter to logaction(). No structured diff is generated in the action_logs.diff column.

The relevant logaction() call is in Koha/Suggestion.pm (~line 79):
  logaction( 'SUGGESTION', $action, $result->suggestionid, $self );

This bug covers updating Koha::Suggestion to capture the pre-change suggestion state and pass it as the sixth argument to logaction(), enabling before/after comparison in the action log viewer.

Since Koha::Suggestion is a Koha::Object subclass, $self->get_from_storage (or an equivalent pre-change snapshot) should be captured before store() and passed as $original for MODIFY actions. For CREATE, $self can serve as the single state captured.
Comment 1 Martin Renvoize (ashimema) 2026-03-09 21:18:30 UTC
Created attachment 195032 [details] [review]
Bug 42030: Populate diff column for suggestion CREATE/MODIFY/DELETE logs

Update suggestion action logging to populate the diff column using the
correct before/after semantics:

- CREATE: empty before-state ({}), new suggestion data as after-state
- MODIFY: pre-change unblessed data as before, post-store object as after
- DELETE: log before the SQL DELETE so the object can still be fetched;
  pass the suggestion as both $infos (info column) and $original (diff
  before-state), logaction sets after-state to {}

Also add tests verifying the diff column is populated for all three actions.