Bug 39334

Summary: Preserve order when saving patron attributes
Product: Koha Reporter: David Gustafsson <glasklas>
Component: PatronsAssignee: David Gustafsson <glasklas>
Status: Pushed to main --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, jonathan.druart, kyle.m.hall, lucas
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26744
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:
Bug Depends on: 26744    
Bug Blocks: 39970    
Attachments: Bug 39334: (follow up) Preserve order when adding patron attributes
Bug 39334: (follow-up) Preserve order when adding patron attributes
Bug 39334: (follow-up) Preserve order when adding patron attributes

Description David Gustafsson 2025-03-14 14:45:14 UTC
A changed introduced in Bug 26744 affects the order in which patron attribtes are saved, so that one no longer can rely on that the attribute ids are assigned in the same order as the data was passed in. This has very minor implications in Koha itself. since attributes are sorted by other columns when retrieved. but many tests in t/db_dependent/api/v1/patrons_extended_attributes.t now fail because of this. This patch makes sure the order is preserved when saving the attributes, and tests should now work again.
Comment 1 David Gustafsson 2025-03-14 14:50:16 UTC
Created attachment 179329 [details] [review]
Bug 39334: (follow up) Preserve order when adding patron attributes

To test:
1) Run tests in t/db_dependent/api/v1/patrons_extended_attributes.t, serveral should fail
2) Apply patch
3) Run the tests in 1) again, all should now pass
Comment 2 Katrin Fischer 2025-03-17 07:12:29 UTC
Hi David, please make sure you are using the newest components (newest ktd, nuke erm_module, yarn install...) - the patch was not tidy. I fixed before pushing and treating this as a follow-up to the original bug
Comment 3 Katrin Fischer 2025-03-17 07:15:17 UTC
Hm, on second thought: since this doesn't fix the tests but changes the code I am asking for a set of QA eyes here too please. Attaching the tidied patch.
Comment 4 Katrin Fischer 2025-03-17 07:15:44 UTC
Created attachment 179377 [details] [review]
Bug 39334: (follow-up) Preserve order when adding patron attributes

To test:
1) Run tests in t/db_dependent/api/v1/patrons_extended_attributes.t, serveral should fail
2) Apply patch
3) Run the tests in 1) again, all should now pass
Comment 5 Jonathan Druart 2025-03-17 11:23:52 UTC
Created attachment 179388 [details] [review]
Bug 39334: (follow-up) Preserve order when adding patron attributes

To test:
1) Run tests in t/db_dependent/api/v1/patrons_extended_attributes.t, serveral should fail
2) Apply patch
3) Run the tests in 1) again, all should now pass

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 David Gustafsson 2025-03-17 14:32:35 UTC
(In reply to Katrin Fischer from comment #2)
> Hi David, please make sure you are using the newest components (newest ktd,
> nuke erm_module, yarn install...) - the patch was not tidy. I fixed before
> pushing and treating this as a follow-up to the original bug

Ok, thanks!
Comment 7 Katrin Fischer 2025-03-19 10:56:38 UTC
Pushed for 25.05!

Well done everyone, thank you!