Bugzilla – Attachment 173550 Details for
Bug 37944
Object deletion should be logged with a JSON diff of changes, implement for items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37944: Log object delete as JSON diff, implement for items
Bug-37944-Log-object-delete-as-JSON-diff-implement.patch (text/plain), 2.32 KB, created by
Martin Renvoize (ashimema)
on 2024-10-28 15:02:08 UTC
(
hide
)
Description:
Bug 37944: Log object delete as JSON diff, implement for items
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-28 15:02:08 UTC
Size:
2.32 KB
patch
obsolete
>From 5ad5140b1b15645ca66284b396c1d55b7f304c4d Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 17 Sep 2024 09:37:26 -0400 >Subject: [PATCH] Bug 37944: Log object delete as JSON diff, implement for > items > >We should store deleted objects as diffs just as we do for modification and item created. >This enhancement will store modification diffs if the action is set to DELETE, and an "original" object is passed in. > >Test Plan: >1) Enable CataloguingLog >2) Deletee an item >3) Query the database for the newest action log: > select * from action_logs order by action_id desc limit 1\G >4) Note the diff column is NULL >5) Apply this patch >6) Restart all the things! >7) Delete another item >8) Query the database again >9) Note the diff has been created! > >Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Log.pm | 9 ++++++++- > Koha/Item.pm | 2 +- > 2 files changed, 9 insertions(+), 2 deletions(-) > >diff --git a/C4/Log.pm b/C4/Log.pm >index 543096259a4..1feb5f4d5c5 100644 >--- a/C4/Log.pm >+++ b/C4/Log.pm >@@ -121,10 +121,17 @@ sub logaction { > my $is_object = blessed($original) && $original->isa('Koha::Object'); > > if ( $actionname =~ /^(ADD|CREATE)$/ ) { >+ > # Log diff against empty hashref for newly created objects >- $updated = $is_object ? $original->unblessed : $original; >+ $updated = $is_object ? $original->unblessed : $original; > $original = {}; >+ } elsif ( $actionname eq 'DELETE' ) { >+ >+ # Log diff for deleted objects against empty hashref >+ $original = $is_object ? $original->unblessed : $original; >+ $updated = {}; > } else { >+ > # Log diff against hashref of pre-modified object if passed in > $original = $is_object ? $original->unblessed : $original; > } >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 1fadb0579ac..ec42c9917c4 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -283,7 +283,7 @@ sub delete { > > $self->_after_item_action_hooks({ action => 'delete' }); > >- logaction( "CATALOGUING", "DELETE", $self->itemnumber, "item" ) >+ logaction( "CATALOGUING", "DELETE", $self->itemnumber, "item", undef, $self ) > if C4::Context->preference("CataloguingLog"); > > Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >-- >2.47.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37944
:
171626
|
171992
| 173550