Bug 9535 - Patron card creator "Remove duplicates" function doesn't work
Summary: Patron card creator "Remove duplicates" function doesn't work
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Chris Nighswonger
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-02 18:23 UTC by Owen Leonard
Modified: 2014-05-26 21:04 UTC (History)
3 users (show)

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


Attachments
Proposed Fix (1.52 KB, patch)
2013-04-02 14:10 UTC, Chris Nighswonger
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 9535 - Patron card creator "Remove duplicates" function doesn't work (1.69 KB, patch)
2013-04-02 14:32 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 9535 - Patron card creator "Remove duplicates" function doesn't work (1.78 KB, patch)
2013-04-03 09:30 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2013-02-02 18:23:21 UTC
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.
Comment 1 Katrin Fischer 2013-03-30 20:45:35 UTC
Upping severity a bit - this is a quite annoying bug!
Comment 2 Chris Nighswonger 2013-03-31 02:05:27 UTC
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'}};
Comment 3 Chris Nighswonger 2013-04-02 14:10:04 UTC Comment hidden (obsolete)
Comment 4 Owen Leonard 2013-04-02 14:32:15 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2013-04-03 09:29:42 UTC
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.
Comment 6 Jonathan Druart 2013-04-03 09:30:02 UTC
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
Comment 7 Jared Camins-Esakov 2013-04-03 10:09:19 UTC
This patch has been pushed to master.
Comment 8 Chris Cormack 2013-04-14 07:27:45 UTC
Pushed to 3.10.x and 3.8.x will be in 3.10.5 and 3.8.12