[Bug 44015] New: Log additional contents changes as a single action with a diff
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 Bug ID: 44015 Summary: Log additional contents changes as a single action with a diff Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Tools Assignee: koha-bugs@lists.koha-community.org Reporter: lisette@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org Depends on: 43988 Blocks: 39538 Target Milestone: --- When AdditionalContentLog is enabled, tools/additional-contents.pl logs one NEWS action per translation, as a pipe-separated string with no object id. Editing an entry with several translations creates several log lines, changes to the display settings (location, library, dates, position) are not logged at all, and the log viewer cannot show a diff or meaningfully compare entries. This was originally part of bug 39538 (CSS snippets) and has been split out, as it affects all additional contents (news, HTML customizations, pages). These patches: - Move the logging into Koha::AdditionalContent / Koha::AdditionalContentsLocalization, so saving a content with its translations is logged as a single ADD, MODIFY or DELETE action, with the content id as object and a JSON diff (ACTN1). - Only record the changed settings and translations in MODIFY actions; saving without changes logs nothing. - Update translations in place instead of deleting and re-creating them, so unchanged ones keep their updated_on. - Diff the nested fields of added and deleted entries field by field (NEWS only in C4::Log), so ADD/DELETE diffs have the same shape as MODIFY ones. - Format the NEWS info and diff in the log viewer and fix the compare checkboxes for these entries. Test plan: 1. Enable AdditionalContentLog 2. Go to Tools > News, add a news item with a default and a translated title/content 3. Edit it: change only the default content, save 4. Edit it again: change only the position and the expiration date, save 5. Save it again without any changes 6. Edit it and remove the translation, save 7. Delete it 8. Repeat 2-7 with an HTML customization (Tools > HTML customizations) 9. Go to Tools > Log viewer, select only the Additional contents module and submit 10. Confirm there is exactly one line per add/edit/delete (none for step 5), the Object column holds the content id, and the Info column only lists what changed 11. Show the Diff column: the ADD, MODIFY and DELETE diffs list the title and content of each language separately, title before content 12. Tick two entries for the same content and click 'View comparison' 13. prove t/db_dependent/Log.t t/db_dependent/Koha/AdditionalContents.t t/db_dependent/AuthoritiesMarc.t t/db_dependent/Koha/Biblio.t Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39538 [Bug 39538] Replace UserCSS system preference with snippets https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43988 [Bug 43988] Setting an additional contents number/position to 0 isn't handled consistently -- 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=44015 --- Comment #1 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 210772 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210772&action=edit Bug 44015: Log additional contents changes as a single action with a diff When AdditionalContentLog is enabled, tools/additional-contents.pl logs one NEWS action per localization, as a pipe-separated string with no object id. Editing an entry with several translations creates several log lines, changes to the display settings (location, library, dates, position) are not logged at all, and the log viewer cannot show a diff or compare entries. This patch moves the logging into the objects: - Koha::AdditionalContent->store accepts translated_contents, so the display settings and the localizations are saved and logged as a single ADD or MODIFY action. A new content without a code gets its default code there. - Localizations are updated in place (matched on lang) instead of being deleted and re-created, so unchanged ones keep their updated_on. - Koha::AdditionalContent->delete deletes the localizations with the content and logs a single DELETE action. - Storing or deleting a localization directly is logged as a MODIFY of its content, unless log_action => 0 is passed. - Only the changed settings and localizations are recorded in MODIFY actions, with the content id as object and a JSON diff. - The log viewer formats the NEWS info, collapses long content, and the compare checkboxes work for these entries. To test: 1. Enable AdditionalContentLog 2. Go to Tools > News, add a news item with a default and a translated title/content 3. Edit it: change only the default content, save 4. Edit it again: change only the position and the expiration date, save 5. Save it again without any changes 6. Edit it and remove the translation, save 7. Delete it 8. Repeat 2-7 with an HTML customization (Tools > HTML customizations) 9. Go to Tools > Log viewer, select only the Additional contents module and submit 10. Confirm there is exactly one line per add/edit/delete (none for step 5), the Object column holds the content id, and the Info column only lists what changed (click 'Show content' to expand it) 11. Show the Diff column and confirm it shows the changes 12. Tick two entries for the same content and click 'View comparison' 13. prove t/db_dependent/Koha/AdditionalContents.t -- 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=44015 --- Comment #2 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 210773 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210773&action=edit Bug 44015: Add unit tests prove t/db_dependent/Koha/AdditionalContents.t -- 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=44015 --- Comment #3 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 210774 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210774&action=edit Bug 44015: Diff the nested fields of added and deleted additional contents C4::Log diffs an added entry against an empty hashref, and a deleted one to an empty hashref, so Struct::Diff reports a nested hash as a single added or removed block. For additional contents, the localizations were logged as one "contents" block on ADD and DELETE while MODIFY reports each title and content by language, so the diffs could not be compared. This patch diffs added and deleted NEWS entries against the skeleton of their nested hashes, so each nested field is reported as added or removed, the way modifications nest them. Other modules are unchanged, as the catalog and authority logs rely on _marc being one block. To test: 1. Enable AdditionalContentLog 2. Add a news item with a default and a translated title/content, edit it, then delete it 3. Go to Tools > Log viewer, select the Additional contents module, show the Diff column 4. Confirm the ADD and DELETE diffs list the title and content of each language separately, like the MODIFY diff 5. prove t/db_dependent/Log.t t/db_dependent/Koha/AdditionalContents.t \ t/db_dependent/AuthoritiesMarc.t t/db_dependent/Koha/Biblio.t -- 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=44015 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |lisette@bywatersolutions.co |ity.org |m -- 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=44015 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Patch doesn't apply -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Patch doesn't apply |Needs Signoff --- Comment #4 from Lisette Scheer <lisette@bywatersolutions.com> --- Rebased -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210772|0 |1 is obsolete| | Attachment #210773|0 |1 is obsolete| | Attachment #210774|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 --- Comment #5 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 210969 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210969&action=edit Bug 44015: Log additional contents changes as a single action with a diff When AdditionalContentLog is enabled, tools/additional-contents.pl logs one NEWS action per localization, as a pipe-separated string with no object id. Editing an entry with several translations creates several log lines, changes to the display settings (location, library, dates, position) are not logged at all, and the log viewer cannot show a diff or compare entries. This patch moves the logging into the objects: - Koha::AdditionalContent->store accepts translated_contents, so the display settings and the localizations are saved and logged as a single ADD or MODIFY action. A new content without a code gets its default code there. - Localizations are updated in place (matched on lang) instead of being deleted and re-created, so unchanged ones keep their updated_on. - Koha::AdditionalContent->delete deletes the localizations with the content and logs a single DELETE action. - Storing or deleting a localization directly is logged as a MODIFY of its content, unless log_action => 0 is passed. - Only the changed settings and localizations are recorded in MODIFY actions, with the content id as object and a JSON diff. - The log viewer formats the NEWS info, collapses long content, and the compare checkboxes work for these entries. To test: 1. Enable AdditionalContentLog 2. Go to Tools > News, add a news item with a default and a translated title/content 3. Edit it: change only the default content, save 4. Edit it again: change only the position and the expiration date, save 5. Save it again without any changes 6. Edit it and remove the translation, save 7. Delete it 8. Repeat 2-7 with an HTML customization (Tools > HTML customizations) 9. Go to Tools > Log viewer, select only the Additional contents module and submit 10. Confirm there is exactly one line per add/edit/delete (none for step 5), the Object column holds the content id, and the Info column only lists what changed (click 'Show content' to expand it) 11. Show the Diff column and confirm it shows the changes 12. Tick two entries for the same content and click 'View comparison' 13. prove t/db_dependent/Koha/AdditionalContents.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 --- Comment #6 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 210970 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210970&action=edit Bug 44015: Add unit tests prove t/db_dependent/Koha/AdditionalContents.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 --- Comment #7 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 210971 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210971&action=edit Bug 44015: Diff the nested fields of added and deleted additional contents C4::Log diffs an added entry against an empty hashref, and a deleted one to an empty hashref, so Struct::Diff reports a nested hash as a single added or removed block. For additional contents, the localizations were logged as one "contents" block on ADD and DELETE while MODIFY reports each title and content by language, so the diffs could not be compared. This patch diffs added and deleted NEWS entries against the skeleton of their nested hashes, so each nested field is reported as added or removed, the way modifications nest them. Other modules are unchanged, as the catalog and authority logs rely on _marc being one block. To test: 1. Enable AdditionalContentLog 2. Add a news item with a default and a translated title/content, edit it, then delete it 3. Go to Tools > Log viewer, select the Additional contents module, show the Diff column 4. Confirm the ADD and DELETE diffs list the title and content of each language separately, like the MODIFY diff 5. prove t/db_dependent/Log.t t/db_dependent/Koha/AdditionalContents.t \ t/db_dependent/AuthoritiesMarc.t t/db_dependent/Koha/Biblio.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210969|0 |1 is obsolete| | Attachment #210970|0 |1 is obsolete| | Attachment #210971|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 --- Comment #8 from David Nind <david@davidnind.com> --- Created attachment 211187 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211187&action=edit Bug 44015: Log additional contents changes as a single action with a diff When AdditionalContentLog is enabled, tools/additional-contents.pl logs one NEWS action per localization, as a pipe-separated string with no object id. Editing an entry with several translations creates several log lines, changes to the display settings (location, library, dates, position) are not logged at all, and the log viewer cannot show a diff or compare entries. This patch moves the logging into the objects: - Koha::AdditionalContent->store accepts translated_contents, so the display settings and the localizations are saved and logged as a single ADD or MODIFY action. A new content without a code gets its default code there. - Localizations are updated in place (matched on lang) instead of being deleted and re-created, so unchanged ones keep their updated_on. - Koha::AdditionalContent->delete deletes the localizations with the content and logs a single DELETE action. - Storing or deleting a localization directly is logged as a MODIFY of its content, unless log_action => 0 is passed. - Only the changed settings and localizations are recorded in MODIFY actions, with the content id as object and a JSON diff. - The log viewer formats the NEWS info, collapses long content, and the compare checkboxes work for these entries. To test: 1. Enable AdditionalContentLog 2. Go to Tools > News, add a news item with a default and a translated title/content 3. Edit it: change only the default content, save 4. Edit it again: change only the position and the expiration date, save 5. Save it again without any changes 6. Edit it and remove the translation, save 7. Delete it 8. Repeat 2-7 with an HTML customization (Tools > HTML customizations) 9. Go to Tools > Log viewer, select only the Additional contents module and submit 10. Confirm there is exactly one line per add/edit/delete (none for step 5), the Object column holds the content id, and the Info column only lists what changed (click 'Show content' to expand it) 11. Show the Diff column and confirm it shows the changes 12. Tick two entries for the same content and click 'View comparison' 13. prove t/db_dependent/Koha/AdditionalContents.t Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 --- Comment #9 from David Nind <david@davidnind.com> --- Created attachment 211188 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211188&action=edit Bug 44015: Add unit tests prove t/db_dependent/Koha/AdditionalContents.t Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 --- Comment #10 from David Nind <david@davidnind.com> --- Created attachment 211189 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211189&action=edit Bug 44015: Diff the nested fields of added and deleted additional contents C4::Log diffs an added entry against an empty hashref, and a deleted one to an empty hashref, so Struct::Diff reports a nested hash as a single added or removed block. For additional contents, the localizations were logged as one "contents" block on ADD and DELETE while MODIFY reports each title and content by language, so the diffs could not be compared. This patch diffs added and deleted NEWS entries against the skeleton of their nested hashes, so each nested field is reported as added or removed, the way modifications nest them. Other modules are unchanged, as the catalog and authority logs rely on _marc being one block. To test: 1. Enable AdditionalContentLog 2. Add a news item with a default and a translated title/content, edit it, then delete it 3. Go to Tools > Log viewer, select the Additional contents module, show the Diff column 4. Confirm the ADD and DELETE diffs list the title and content of each language separately, like the MODIFY diff 5. prove t/db_dependent/Log.t t/db_dependent/Koha/AdditionalContents.t \ t/db_dependent/AuthoritiesMarc.t t/db_dependent/Koha/Biblio.t Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44015 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com Text to go in the| |This enhancement improves release notes| |the logging for the | |additional contents tool | |(when the | |AdditionalContentLog system | |preference is set to | |"Log"). | | | |Improvements to the log | |viewer include: | |- Object column: shows the | |ID for the additional | |content | |- Info column - easier to | |read: now easier to read | |with field titles and | |details listed (with the | |field heading in bold) and | |a collapsible "Show | |content" section | |- Info column - compare: | |the compare function is now | |available, so you can now | |see what is different | |between two log entries | |- Diff column (when shown): | |now shows a table with the | |information for each field, | |along with the before and | |after content (additions | |are shown in green and | |removals are shown in red) | |(instead of a | |JSON-formatted entry) | |- Translated content: one | |log entry for all content | |changes, includes both the | |default and specific | |language changes for | |translated content (instead | |of separate entries for | |each language), with | |details for each language | |shown separately --- Comment #11 from David Nind <david@davidnind.com> --- I've attempted a release note, please feel free to update with corrections and improvements. It is really nice to have these logging improvements added for more things! I'm assuming the compare feature is standard. I did notice one oddity with it, but am assuming it is the default behavour: 1. Have a news item with both default and English content (title and content). 2. Change only the content for the default entry 3. There are two og entries, one for the add and one for the modify. 4. Using the compare feature, fields that are not changed are crossed out (red with a strike through), for example the Location and Publication date fields. 5. That makes sense as it is doing a comparison between the two "Info" columns and these fields weren't changed so don't show any details in the Info column. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org