| Summary: | Add diff support to AUTHORITIES action logs | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Martin Renvoize (ashimema) <martin.renvoize> |
| Component: | Transaction logs | Assignee: | Martin Renvoize (ashimema) <martin.renvoize> |
| Status: | Signed Off --- | QA Contact: | Testopia <testopia> |
| Severity: | enhancement | ||
| Priority: | P5 - low | CC: | david |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | Small patch |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: |
This enhancement adds a 'diff' to the action logs when modifying an authority record (creating, modifying, and deleting).
Previously, no diff was recorded (although some information was recorded in the Info column).
|
Version(s) released in: | |
| Circulation function: | |||
| Bug Depends on: | 40135 | ||
| Bug Blocks: | 37940 | ||
| Attachments: |
Bug 42032: Include MARC field changes in AUTHORITIES diff logs
Bug 42032: Include MARC field changes in AUTHORITIES diff logs |
||
|
Description
Martin Renvoize (ashimema)
2026-03-09 15:36:43 UTC
Created attachment 195021 [details] [review] Bug 42032: Include MARC field changes in AUTHORITIES diff logs The AUTHORITIES action log entries for authority operations previously stored minimal data: ADD and DELETE logged just the string "authority", while MODIFY logged a raw MARC-formatted dump of the pre-change record as a plain text string ("authority BEFORE=>..."). None of these populated the diff column. This patch updates AddAuthority, ModAuthority and DelAuthority in C4/AuthoritiesMarc.pm to follow the same pattern introduced for biblios in bug 40135: passing combined hashrefs to logaction so that the diff column is automatically populated with Struct::Diff JSON. The combined hashref contains the auth_header table columns (authtypecode, heading, origincode, etc. — excluding the raw marcxml blob) plus a _marc key built by the new _marc_record_to_diffable helper, which converts a MARC::Record into a tag => array-of-formatted-strings structure readable by the existing diff viewer. A new _authority_log_data helper packages the authority unblessed data and MARC record into the combined hashref, keeping the three call sites concise. For ADD, the logaction is now emitted after the authority record has been fully stored (after _after_authority_action_hooks), so the diff captures the complete saved state. For MODIFY, the before-state is captured from Koha::Authorities before calling AddAuthority, and the after-state is read back once AddAuthority has committed the new data. For DELETE, the MARC is captured before the authority is removed. The diff column for MODIFY will now show both authority table column changes (e.g. heading) and MARC field-level changes (e.g. _marc.151.0) in the existing diff viewer table in the log viewer. Tests are added to verify that ADD, MODIFY, and DELETE all populate the diff column and that _marc content is captured correctly. Created attachment 195024 [details] [review] Bug 42032: Include MARC field changes in AUTHORITIES diff logs The AUTHORITIES action log entries for authority operations previously stored minimal data: ADD and DELETE logged just the string "authority", while MODIFY logged a raw MARC-formatted dump of the pre-change record as a plain text string ("authority BEFORE=>..."). None of these populated the diff column. This patch updates AddAuthority, ModAuthority and DelAuthority in C4/AuthoritiesMarc.pm to follow the same pattern introduced for biblios in bug 40135: passing combined hashrefs to logaction so that the diff column is automatically populated with Struct::Diff JSON. The combined hashref contains the auth_header table columns (authtypecode, heading, origincode, etc. — excluding the raw marcxml blob) plus a _marc key built by the new _marc_record_to_diffable helper, which converts a MARC::Record into a tag => array-of-formatted-strings structure readable by the existing diff viewer. A new _authority_log_data helper packages the authority unblessed data and MARC record into the combined hashref, keeping the three call sites concise. For ADD, the logaction is now emitted after the authority record has been fully stored (after _after_authority_action_hooks), so the diff captures the complete saved state. For MODIFY, the before-state is captured from Koha::Authorities before calling AddAuthority, and the after-state is read back once AddAuthority has committed the new data. For DELETE, the MARC is captured before the authority is removed. The diff column for MODIFY will now show both authority table column changes (e.g. heading) and MARC field-level changes (e.g. _marc.151.0) in the existing diff viewer table in the log viewer. Tests are added to verify that ADD, MODIFY, and DELETE all populate the diff column and that _marc content is captured correctly. Signed-off-by: David Nind <david@davidnind.com> |