Bug 38266

Summary: Incorrect attribute disabled in patron batch modification
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: ToolsAssignee: Nick Clemens (kidclamp) <nick>
Status: RESOLVED FIXED QA Contact: Emily Lamancusa (emlam) <emily.lamancusa>
Severity: minor    
Priority: P5 - low CC: emily.lamancusa, fridolin.somers, jesse, lucas, martin.renvoize, phil
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38187
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.06,23.11.11
Circulation function:
Bug Depends on: 21083    
Bug Blocks:    
Attachments: Bug 38266: (bug 21083 follow-up) Increment after comparison
Bug 38266: (bug 21083 follow-up) Increment after comparison
Bug 38266: (bug 21083 follow-up) Increment after comparison

Description Nick Clemens (kidclamp) 2024-10-24 18:17:17 UTC
Bug 21083 moved from a loop of checking disabled attributes to a grep.

When looping we did ++$i for each iteration

For the grep we need to check the current i before incrementing, but we are doing the increment first here:
$attributes->{$code}->{disabled} = grep { $_ eq sprintf("attr%s_value", ++$i) } @disabled;

Just need to move the pluses to the right
Comment 1 Nick Clemens (kidclamp) 2024-10-24 18:21:51 UTC
Created attachment 173304 [details] [review]
Bug 38266: (bug 21083 follow-up) Increment after comparison

To test:
 1 - Define a patron attribute as repeatable
 2 - Add multiple values to a patron (I used borrowernumber 5)
 3 - Tools->Batch patron modification
 4 - Modify the patron from step 1, selecting the attribute you created and checking the box to clear
 5 - View the patron, they look correct
 6 - Check the DB:
    SELECT * FROM borrower_attributes WHERE borrowernumber=5;
 7 - There is one blank value
 8 - Apply patch
 9 - Repeat batch modification
10 - Check the DB, no attribute!
11 - Test with multiple attributes in the batch modification and ensure only the correct one is removed
12 - Sign off
Comment 2 Phil Ringnalda 2024-10-25 11:31:34 UTC
Created attachment 173348 [details] [review]
Bug 38266: (bug 21083 follow-up) Increment after comparison

To test:
 1 - Define a patron attribute as repeatable
 2 - Add multiple values to a patron (I used borrowernumber 5)
 3 - Tools->Batch patron modification
 4 - Modify the patron from step 1, selecting the attribute you created and checking the box to clear
 5 - View the patron, they look correct
 6 - Check the DB:
    SELECT * FROM borrower_attributes WHERE borrowernumber=5;
 7 - There is one blank value
 8 - Apply patch, restart_all
 9 - Repeat batch modification
10 - Check the DB, no attribute!
11 - Test with multiple attributes in the batch modification and ensure only the correct one is removed
12 - Sign off

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Comment 3 Emily Lamancusa (emlam) 2024-10-28 17:29:23 UTC
Created attachment 173579 [details] [review]
Bug 38266: (bug 21083 follow-up) Increment after comparison

To test:
 1 - Define a patron attribute as repeatable
 2 - Add multiple values to a patron (I used borrowernumber 5)
 3 - Tools->Batch patron modification
 4 - Modify the patron from step 1, selecting the attribute you created and checking the box to clear
 5 - View the patron, they look correct
 6 - Check the DB:
    SELECT * FROM borrower_attributes WHERE borrowernumber=5;
 7 - There is one blank value
 8 - Apply patch
 9 - Repeat batch modification
10 - Check the DB, no attribute!
11 - Test with multiple attributes in the batch modification and ensure only the correct one is removed
12 - Sign off

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Comment 4 Katrin Fischer 2024-10-30 06:48:52 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 5 Martin Renvoize (ashimema) 2024-11-28 16:54:24 UTC
This is needed for 23.11 and 23.05 too
Comment 6 Lucas Gass (lukeg) 2024-12-05 21:12:50 UTC
Backported to 24.05.x for upcoming 24.05.06
Comment 7 Fridolin Somers 2024-12-18 09:31:19 UTC
Pushed to 23.11.x for 23.11.11
Comment 8 Jesse Maseto 2025-02-03 16:35:36 UTC
Not pushed to LTS. Marked Resolved.

If you feel this should be in LTS please reply with your reason.