Bug 32306 - Hold modifications don't log correctly
Summary: Hold modifications don't log correctly
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Transaction logs (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Emmi Takkinen
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-21 13:45 UTC by Emmi Takkinen
Modified: 2023-01-23 16:10 UTC (History)
1 user (show)

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


Attachments
Bug 32306: Add unit tests (4.24 KB, patch)
2022-11-24 12:44 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 32306: Log after storing changes in ModReserve (2.44 KB, patch)
2022-11-24 12:45 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 32306: Add unit tests (4.23 KB, patch)
2023-01-23 16:10 UTC, Emily Lamancusa
Details | Diff | Splinter Review
Bug 32306: Log after storing changes in ModReserve (2.50 KB, patch)
2023-01-23 16:10 UTC, Emily Lamancusa
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Emmi Takkinen 2022-11-21 13:45:57 UTC
When one modifies holds from records holds page, these changes don't log into action_logs table correctly. Instead holds data before modifications is stored to action_logs.

To test:
1. Find hold to modify.
2. If possible, locate this hold from action_logs table:
SELECT * FROM action_logs WHERE module = "HOLDS" AND object = <reserve_id>; 
3. Modify hold, change its pickup library from A to B.
4. Save changes.
5. Take a look at action_logs table.
=> Modification is saved, but holds pickup library is still A.
6. Modify hold again, e.g add expiration date.
7. Save.
=> Expiration date is empty, but pickup library is now B.
Comment 1 Emmi Takkinen 2022-11-24 12:44:45 UTC
Created attachment 144215 [details] [review]
Bug 32306: Add unit tests

In ModReserves logging changes actually happens
before we store any of made changes.

To test:
1. Run prove t/db_dependent/Reserves.t
=> Tests should fail.

Sponsored-by: Koha-Suomi Oy
Comment 2 Emmi Takkinen 2022-11-24 12:45:27 UTC
Created attachment 144216 [details] [review]
Bug 32306: Log after storing changes in ModReserve

When one modifies holds from records holds page, these
changes don't log into action_logs table correctly.
Instead holds data before modifications is stored to action_logs.

This patch moves call for logaction after changes have
been stored in ModReserve.

To test:
1. Find hold to modify.
2. If possible, locate this hold from action_logs table:
SELECT * FROM action_logs WHERE module = "HOLDS" AND object = <reserve_id>;
3. Modify hold, change its pickup library from A to B.
4. Save changes.
5. Take a look at action_logs table.
=> Modification is saved, but holds pickup library is still A.
6. Modify hold again, e.g add expiration date.
7. Save.
8. Find this new modification from action_logs.
=> In action_logs table expiration date is empty, but pickup library is now B.
9. Apply this patch.
10. Modify hold, change its pickup library back from B to A.
11. Save changes.
=> In action_logs table holds modification has now a correct pickup library A.

Also prove t/db_dependent/Reserves.t.

Sponsored-by: Koha-Suomi Oy
Comment 3 Emily Lamancusa 2023-01-23 16:10:27 UTC
Created attachment 145587 [details] [review]
Bug 32306: Add unit tests

In ModReserves logging changes actually happens
before we store any of made changes.

To test:
1. Run prove t/db_dependent/Reserves.t
=> Tests should fail.

Sponsored-by: Koha-Suomi Oy
Comment 4 Emily Lamancusa 2023-01-23 16:10:31 UTC
Created attachment 145588 [details] [review]
Bug 32306: Log after storing changes in ModReserve

When one modifies holds from records holds page, these
changes don't log into action_logs table correctly.
Instead holds data before modifications is stored to action_logs.

This patch moves call for logaction after changes have
been stored in ModReserve.

To test:
1. Find hold to modify.
2. If possible, locate this hold from action_logs table:
SELECT * FROM action_logs WHERE module = "HOLDS" AND object = <reserve_id>;
3. Modify hold, change its pickup library from A to B.
4. Save changes.
5. Take a look at action_logs table.
=> Modification is saved, but holds pickup library is still A.
6. Modify hold again, e.g add expiration date.
7. Save.
8. Find this new modification from action_logs.
=> In action_logs table expiration date is empty, but pickup library is now B.
9. Apply this patch.
10. Modify hold, change its pickup library back from B to A.
11. Save changes.
=> In action_logs table holds modification has now a correct pickup library A.

Also prove t/db_dependent/Reserves.t.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>