From 4a0c30d4914d740bd8e2464706b149724bb6efdc Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Fri, 26 Aug 2011 16:19:13 -0400 Subject: [PATCH] SIP2 Checkout "no-code" failure fix Instead of assuming that code exists on a response do more checks. Specifically, a response code can be empty but not zero when there is no defined event code for the failure code. An easily tested case of this is standing penalties. Signed-off-by: Thomas Berezansky Signed-off-by: Bill Erickson --- .../lib/OpenILS/SIP/Transaction/Checkout.pm | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm index bcfdc3bb79..ab8d17a1cc 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm @@ -91,27 +91,27 @@ sub do_checkout { syslog('LOG_DEBUG', "OILS: $method returned event: " . OpenSRF::Utils::JSON->perl2JSON($resp)); - if (@$resp > 1 || $U->event_code($$resp[0])) { + my $first_code = $U->event_code($$resp[0]); + if (@$resp > 1 || !defined $first_code || $first_code ne '0') { # We got one or more non-success events $self->screen_msg(''); for my $r (@$resp) { - if ( my $code = $U->event_code($r) ) { - my $txt = $r->{textcode}; - syslog('LOG_INFO', "OILS: $method failed with event $code : $txt"); - - if ($override_events{$txt} && $method !~ /override$/) { - # Found an event we've been configured to override. - $override = 1; - } elsif ($txt =~ /ITEM_(?:DEPOSIT|RENTAL)_FEE_REQUIRED/ && $self->fee_ack) { - # Patron acknowledged the fee. - $override = 1; - } elsif ( $txt eq 'OPEN_CIRCULATION_EXISTS' ) { - $self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS); - return 0; - } else { - $self->screen_msg(OILS_SIP_MSG_CIRC_PERMIT_FAILED); - return 0; - } + my $code = $U->event_code($r); + my $txt = $r->{textcode}; + syslog('LOG_INFO', "OILS: $method failed with event $code : $txt"); + + if ($override_events{$txt} && $method !~ /override$/) { + # Found an event we've been configured to override. + $override = 1; + } elsif ($txt =~ /ITEM_(?:DEPOSIT|RENTAL)_FEE_REQUIRED/ && $self->fee_ack) { + # Patron acknowledged the fee. + $override = 1; + } elsif ( $txt eq 'OPEN_CIRCULATION_EXISTS' ) { + $self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS); + return 0; + } else { + $self->screen_msg(OILS_SIP_MSG_CIRC_PERMIT_FAILED); + return 0; } } # This looks potentially dangerous, but we shouldn't -- 2.11.0