From 6dfdbb0154e7615d59612561231f2ab75687e3e2 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 17 Jun 2014 15:14:12 -0400 Subject: [PATCH] LP#1331127 Repair sort logic of previous issuances Ensure that the list of previous issuances is sorted correctly (on date_published) when looking for the previous serial.unit to update its copy location (when serial.prev_issuance_copy_location is enabled). The data comes sorted from the DB, but the sorting was lost during the process of unique-ifying the list. Ultimately, it was relying on the order of hash keys, which is undefined. Signed-off-by: Bill Erickson Signed-off-by: Dan Wells --- .../src/perlmods/lib/OpenILS/Application/Serial.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm index 35bcc82b03..60b7383c4c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Serial.pm @@ -1497,8 +1497,14 @@ sub _issuances_received { } }) or return $e->die_event; - my $uniq = +{map { $_->{"issuance"} => 1 } @$results}; - return [ map { $e->retrieve_serial_issuance($_) } keys %$uniq ]; + my %seen; + my $issuances = []; + for my $iss_id (map { $_->{"issuance"} } @$results) { + next if $seen{$iss_id}; + $seen{$iss_id} = 1; + push(@$issuances, $e->retrieve_serial_issuance($iss_id)); + } + return $issuances; } # _prepare_unit populates the detailed_contents, summary_contents, and -- 2.43.2