Bug 35630

Summary: Add ability to log changes to authorized values
Product: Koha Reporter: Donna <bwsdonna>
Component: System AdministrationAssignee: Sam Lau <samalau>
Status: Needs Signoff --- QA Contact:
Severity: enhancement    
Priority: P5 - low CC: alban.peyrat_koha, angela.berrett, chris.rowlands6, gmcharlt, kebliss, kyle, laura, lucas, roman.dolny, samalau
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on:    
Bug Blocks: 22794    
Attachments: Bug 35630: Add new system preference 'AuthorizedValuesLog'
Bug 35630: Add ability to log creation, modification, and deletion of authorized values
Bug 35630: Handle library limits inside the store function
Bug 35630: Add new system preference 'AuthorizedValuesLog'
Bug 35630: Add ability to log creation, modification, and deletion of authorized values
Bug 35630: Handle library limits inside the store function
Bug 35630: Move Data::Dump to AuthorisedValue.pm

Description Donna 2023-12-21 18:09:31 UTC
With the increase in number of authorized values, and with the newer sys pref CreateAVFromCataloguing, it is becoming essential to be able to determine who/when/how changes are made to authorized values, and this not currently being logged.  It would be a great help to be able to log these changes.
Comment 1 Laura O'Neil 2024-01-18 20:25:34 UTC
+1, this would be extremely useful.
Comment 2 Chris Rowlands 2024-07-08 08:00:48 UTC
As a system librarian trying to work out if I've made a change to an auth value, or someone else did it without my input, I'd love this feature to exist!
Comment 3 Sam Lau 2024-07-10 15:15:36 UTC
Created attachment 168747 [details] [review]
Bug 35630: Add new system preference 'AuthorizedValuesLog'
Comment 4 Sam Lau 2024-07-10 15:15:38 UTC
Created attachment 168748 [details] [review]
Bug 35630: Add ability to log creation, modification, and deletion of authorized values

These patches enable librarians to log any changes to authorized values. The feature is dependent on the new 'AuthorizedValuesLog' system preference.

To test:
1) Apply patch, updatedatabase, restart_all
2) In Administration->System preferences, search for 'AuthorizedValuesLog' and change to 'Log'. Save your changes.
3) Now go to Administration->Authorized values. Keep this tab open
4) In a new tab, go to Tools -> Log viewer. Ensure that "Authorized values" is checked.
5) Now in AV, click on a category and create a new authorized value.
6) Refresh your log viewer, and the creation should be logged appropiately.
7) Modify an authroized value, this should also be logged correctly.
8) Now delete and authorized value, ensure the logging is correct here as well.
9) Now turn off the system preferece.
10) In the log viewer, 'Authorized values' should have a black triangle next to it, indicating the preference is turned off.
11) Change an AV, this should not be logged.
Comment 5 Roman Dolny 2024-07-10 17:57:24 UTC
It works as described it test plan, but:

1. QA - Not blocker: Sysprefs IntranetAddMastheadLibraryPulldown is bad placed (see bug 10610)

2. What should be recorded into 'info' column in action_logs table? Value before modification or value after mod.? For bibliographic record it is value before modification.
Comment 6 Sam Lau 2024-07-10 18:12:06 UTC
(In reply to Roman Dolny from comment #5)
> It works as described it test plan, but:
> 
> 1. QA - Not blocker: Sysprefs IntranetAddMastheadLibraryPulldown is bad
> placed (see bug 10610)

This is unrelated to this bug.

> 2. What should be recorded into 'info' column in action_logs table? Value
> before modification or value after mod.? 

I would think the value after modification. If you wanted to see the value before modifcation, then you would just go back into the logs. 

> For bibliographic record it is value before modification.

I see what you are saying about editing a record, but there's examples where it goes the other way as well. For example, when editing a specific item, the logs show the value after. I think this is better behavior
Comment 7 Roman Dolny 2024-07-10 19:02:19 UTC
(In reply to Sam Lau from comment #6)
> 
> ...
> 
> > 2. What should be recorded into 'info' column in action_logs table? Value
> > before modification or value after mod.? 
> 
> I would think the value after modification. If you wanted to see the value
> before modifcation, then you would just go back into the logs. 
> 

This works for new values and subsequent modifications of values before logging begins. But not for the first modification of values currently existing in the database. (But I'm not sure if this is really important.)

Maybe we should record the old and new value in the "info" column?
Comment 8 Lucas Gass (lukeg) 2024-07-10 19:57:31 UTC
> Maybe we should record the old and new value in the "info" column?

I think that is confusing. Why not just log the new value as MODIFY?
Comment 9 Katrin Fischer 2024-07-11 12:49:04 UTC
We pushed bug 25159 to the end of the cycle and I feel like we should make use of it when adding new logs now.
Adding Kyle and also a topic to next meeting agenda:
https://wiki.koha-community.org/w/index.php?title=Development_IRC_meeting_17_July_2024&action=submit
Comment 10 Sam Lau 2024-07-15 19:10:26 UTC
Created attachment 169027 [details] [review]
Bug 35630: Handle library limits inside the store function

This patch makes use of the diff action_logs as mentioned in comment 9. Furthermore, to fix the issue of calling store twice when creating a new AV, the "replace_library_limits" call has been moved inside to the store function.

Use test plan from previous patch to test.
Comment 11 Roman Dolny 2024-07-16 14:50:55 UTC
Created attachment 169044 [details] [review]
Bug 35630: Add new system preference 'AuthorizedValuesLog'

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 12 Roman Dolny 2024-07-16 14:50:58 UTC
Created attachment 169045 [details] [review]
Bug 35630: Add ability to log creation, modification, and deletion of authorized values

These patches enable librarians to log any changes to authorized values. The feature is dependent on the new 'AuthorizedValuesLog' system preference.

To test:
1) Apply patch, updatedatabase, restart_all
2) In Administration->System preferences, search for 'AuthorizedValuesLog' and change to 'Log'. Save your changes.
3) Now go to Administration->Authorized values. Keep this tab open
4) In a new tab, go to Tools -> Log viewer. Ensure that "Authorized values" is checked.
5) Now in AV, click on a category and create a new authorized value.
6) Refresh your log viewer, and the creation should be logged appropiately.
7) Modify an authroized value, this should also be logged correctly.
8) Now delete and authorized value, ensure the logging is correct here as well.
9) Now turn off the system preferece.
10) In the log viewer, 'Authorized values' should have a black triangle next to it, indicating the preference is turned off.
11) Change an AV, this should not be logged.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 13 Roman Dolny 2024-07-16 14:51:00 UTC
Created attachment 169046 [details] [review]
Bug 35630: Handle library limits inside the store function

This patch makes use of the diff action_logs as mentioned in comment 9. Furthermore, to fix the issue of calling store twice when creating a new AV, the "replace_library_limits" call has been moved inside to the store function.

Use test plan from previous patch to test.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 14 Lucas Gass (lukeg) 2024-09-26 17:45:09 UTC
Failing tests with this patch applied. Probably need to add tests here to cover the change?
Comment 15 Lucas Gass (lukeg) 2024-10-10 15:53:21 UTC
Maybe instead of converting the object to in Log.pm ( $infos = Data::Dumper::Dumper( $infos ) if ref $infos; ) which makes me a bit nervous it could be done in AuthorisedValue.pm and only when dealing with AUTHORIZEDVALUE changes?
Comment 16 Lucas Gass (lukeg) 2024-10-10 15:55:14 UTC
Created attachment 172629 [details] [review]
Bug 35630: Move Data::Dump to AuthorisedValue.pm
Comment 17 Lucas Gass (lukeg) 2024-10-10 15:59:50 UTC
I think it's prudent to now get a 2nd sign-off, returning this one to NSO.