We should store newly created objects as diffs just as we do for modifications. This enhancement will store modification diffs if the action is set to ADD or CREATE, and an "original" object is passed in.
Created attachment 171624 [details] [review] Bug 37943: Log object create as JSON diff, implement for items We should store newly created objects as diffs just as we do for modifications. This enhancement will store modification diffs if the action is set to ADD or CREATE and an "original" object is passed in. Test Plan: 1) Enable CataloguingLog 2) Create 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) Create another item 8) Query the database again 9) Note the diff has been created!
Created attachment 171996 [details] [review] Bug 37943: Log object create as JSON diff, implement for items We should store newly created objects as diffs just as we do for modifications. This enhancement will store modification diffs if the action is set to ADD or CREATE and an "original" object is passed in. Test Plan: 1) Enable CataloguingLog 2) Create 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) Create another item 8) Query the database again 9) Note the diff has been created! Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com>
Created attachment 173549 [details] [review] Bug 37943: Log object create as JSON diff, implement for items We should store newly created objects as diffs just as we do for modifications. This enhancement will store modification diffs if the action is set to ADD or CREATE and an "original" object is passed in. Test Plan: 1) Enable CataloguingLog 2) Create 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) Create 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>
Can we please get some unit tests for the change to Log.pm?
Pushed for 24.11! Well done everyone, thank you!
I don't think ->store should call discard_changes. If you need an additional fetch then do it before logging, don't you think?
(In reply to Jonathan Druart from comment #6) > I don't think ->store should call discard_changes. If you need an additional > fetch then do it before logging, don't you think? Nevermind, forget that. There was one additional fetch already - $self->get_from_storage->_after_item_action_hooks({ action => $action }); + $self->_after_item_action_hooks({ action => $action });
t/db_dependent/Circulation/CalcFine.t .. 1/7 # Failed test 'Amount is calculated correctly' # at t/db_dependent/Circulation/CalcFine.t line 271. # got: '0' # expected: '6' # Looks like you failed 1 test of 2. See bug 37943
(In reply to Jonathan Druart from comment #8) > t/db_dependent/Circulation/CalcFine.t .. 1/7 > # Failed test 'Amount is calculated correctly' > # at t/db_dependent/Circulation/CalcFine.t line 271. > # got: '0' > # expected: '6' > # Looks like you failed 1 test of 2. > > > See bug 37943 Did this get fixed? Main is passing this test for me.
Sorry wrong bug, it was bug 38303.
Enhancement, no 24.05.x backport.