Bug 42030

Summary: Add diff support to SUGGESTION action logs
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: Transaction logsAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
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:
Bug Depends on:    
Bug Blocks: 37940    
Attachments: Bug 42030: Populate diff column for suggestion CREATE/MODIFY/DELETE logs

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.