From 203659ee60b25614eecd01f69e23e3be57952707 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Wed, 6 Jan 2016 12:56:24 +0000 Subject: [PATCH] Bug 15479 Make ILS cardnumber comparison case insensitive The borrowers table is defined COLLATE=utf8_unicode_ci which means that cardnumbers may be saved in either lowercase or uppercase and these are considered equivalent. The server was performing a case sensitive comparison between the incoming patron identifier and that retrieved from the db As a result some renewals were rejected as being on loan to another borrower if the stored cardnumber differed in case. Make code comparison comply with db. Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com --- C4/SIP/ILS.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 7d702b79fa..d6117c0f6d 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -146,8 +146,7 @@ sub checkout { # holds checked inside do_checkout # } elsif ($item->hold_queue && @{$item->hold_queue} && ! $item->barcode_is_borrowernumber($patron_id, $item->hold_queue->[0]->{borrowernumber})) { # $circ->screen_msg("Item on Hold for Another User"); - } elsif ($item->{patron} && ($item->{patron} ne $patron_id)) { - # I can't deal with this right now + } elsif ($item->{patron} && !_ci_cardnumber_cmp($item->{patron},$patron_id)) { $circ->screen_msg("Item checked out to another patron"); } else { $circ->do_checkout(); @@ -155,7 +154,7 @@ sub checkout { $debug and warn "circ is ok"; # If the item is already associated with this patron, then # we're renewing it. - $circ->renew_ok($item->{patron} && ($item->{patron} eq $patron_id)); + $circ->renew_ok($item->{patron} && _ci_cardnumber_cmp($item->{patron}, $patron_id)); $item->{patron} = $patron_id; $item->{due_date} = $circ->{due}; @@ -174,6 +173,13 @@ sub checkout { return $circ; } +sub _ci_cardnumber_cmp { + my ( $s1, $s2) = @_; + # As the database is case insensitive we need to normalize two strings + # before comparing them + return ( uc($s1) eq uc($s2) ); +} + sub checkin { my ( $self, $item_id, $trans_date, $return_date, $current_loc, $item_props, $cancel, $checked_in_ok ) = @_; my ( $patron, $item, $circ ); -- 2.39.5