Bug 21809 - Deleting a request does not delete its log entries
Summary: Deleting a request does not delete its log entries
Status: CLOSED WONTFIX
Alias: None
Product: Koha
Classification: Unclassified
Component: ILL (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact:
URL:
Keywords:
Depends on: 21810
Blocks:
  Show dependency treegraph
 
Reported: 2018-11-12 14:28 UTC by Andrew Isherwood
Modified: 2023-12-28 20:42 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Isherwood 2018-11-12 14:28:14 UTC
Bug 20750 adds the ability for events on ILL requests to be logged in the action logs. Currently changes to request status can be logged.

However, when a request is deleted, the logs associated with that request are not. Since the request ID then becomes available, the next time a request is created, it will re-use the ID of the deleted request and instantly be associated with the log entries for that request.

It's not currently possible to fix this since C4::Log doesn't provide any methods to delete log entries. So I'm going to add an enhancement bug for that.
Comment 1 Katrin Fischer 2018-11-12 18:35:59 UTC
Would one option be to not reuse the ID? Or have a real PK that is used instead of the ID used?
Comment 2 Andrew Isherwood 2018-11-13 15:12:49 UTC
illrequests.illrequest_id is an auto_increment column, which is inline with the vast majority of primary key columns in Koha. Googling around suggests that MySQL/MariaDB shouldn't reuse deleted values in auto_increment columns, which was always my understanding also.

However, I'm seeing log entries associated with requests where the log entries are dated before the request was created. My assumption was that IDs were being re-used, though, I have failed to replicate that behaviour. So perhaps the problem is not caused by that after all.

I believe though that the bug is still valid. If a request is deleted, its log entries should be also. Due to the inability to create a foreign key on action_logs.object (due it potentially referring to many different keys), and therefore the inability to create a cascade, I believe we should do this cleanup manually.
Comment 3 Katrin Fischer 2023-01-13 14:55:52 UTC
I believe this might be a WONTFIX since we never clean up action_logs if something is deleted (the action_logs usually also contain the information, that something WAS deleted in the first place).

Then you can use cleanup_database.pl to clean action_logs:
 https://git.koha-community.org/Koha-community/Koha/src/branch/master/misc/cronjobs/cleanup_database.pl

   --log-modules      Specify which action log modules to trim. Repeatable.
   --preserve-log     Specify which action logs to exclude. Repeatable.
   --logs DAYS        purge entries from action_logs older than DAYS days.
                      Defaults to 180 days if no days specified.