If I add patrons to a batch in the patron card creator, then click the "Remove duplicates" button, all but the first patron in my batch is removed even though the rest were not duplicates.
Upping severity a bit - this is a quite annoying bug!
I won't have time to work up a patch until later next week, but here's the fix: C4::Creators::Batch line 202 should read as follows: my @duplicate_items = grep{$_->{'item_number'} ? $seen{$_->{'item_number'}}++ : $seen{$_->{'borrower_number'}}++} @{$self->{'items'}};
Created attachment 17130 [details] [review] Proposed Fix
Created attachment 17132 [details] [review] [SIGNED-OFF] Bug 9535 - Patron card creator "Remove duplicates" function doesn't work This bug was due to a difference in field names used in the item data for items versus patrons. This patch adds a ternary to discern between the two. To test: Before applying patch: 1. Create a batch of patroncards with one duplicate. 2. Run the de-duplication on the batch. 3. Note that all patrons beyond the first in the batch are now deleted. After applying patch: 4. Repeat steps 1-2. 5. Note that only the duplicate patron is removed. Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu> Signed-off-by: Owen Leonard <oleonard@myacpl.org> Tested successfully with both patron card batches and label batches.
QA comment: Works great. With the patch, I added some duplicates, clicked on the "Remove duplicates" button and the deduplication works as expected. Marked as Passed QA.
Created attachment 17161 [details] [review] Bug 9535 - Patron card creator "Remove duplicates" function doesn't work This bug was due to a difference in field names used in the item data for items versus patrons. This patch adds a ternary to discern between the two. To test: Before applying patch: 1. Create a batch of patroncards with one duplicate. 2. Run the de-duplication on the batch. 3. Note that all patrons beyond the first in the batch are now deleted. After applying patch: 4. Repeat steps 1-2. 5. Note that only the duplicate patron is removed. Signed-off-by: Chris Nighswonger <cnighswonger@foundations.edu> Signed-off-by: Owen Leonard <oleonard@myacpl.org> Tested successfully with both patron card batches and label batches. Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> Add indentation for readability
This patch has been pushed to master.
Pushed to 3.10.x and 3.8.x will be in 3.10.5 and 3.8.12