From: Chris Nighswonger Date: Tue, 2 Apr 2013 14:05:46 +0000 (-0400) Subject: Bug 9535 - Patron card creator "Remove duplicates" function doesn't work X-Git-Tag: v3.12.00-beta3~161^2 X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=commitdiff_plain;h=c70c7185dc6b28151fa9a28e4b2aa13a52d9fc23;p=srvgit 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 Signed-off-by: Owen Leonard Tested successfully with both patron card batches and label batches. Signed-off-by: Jonathan Druart Add indentation for readability Signed-off-by: Jared Camins-Esakov --- diff --git a/C4/Creators/Batch.pm b/C4/Creators/Batch.pm index 9306263f73..28beeb7ed6 100644 --- a/C4/Creators/Batch.pm +++ b/C4/Creators/Batch.pm @@ -199,7 +199,11 @@ sub remove_duplicates { my %seen=(); my $query = "DELETE FROM creator_batches WHERE label_id = ?;"; # ORDER BY timestamp ASC LIMIT ?;"; my $sth = C4::Context->dbh->prepare($query); - my @duplicate_items = grep{$seen{$_->{'item_number'}}++} @{$self->{'items'}}; + my @duplicate_items = grep{ + $_->{'item_number'} + ? $seen{$_->{'item_number'}}++ + : $seen{$_->{'borrower_number'}}++ + } @{$self->{'items'}}; foreach my $item (@duplicate_items) { $sth->execute($item->{'label_id'}); if ($sth->err) {