From c61e33e6f0962026c32a9be80b05cb20ab17d7b7 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Tue, 11 Aug 2015 16:51:53 +0100 Subject: [PATCH] Bug 14673: Work around change to AddIssue return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return from AddIssue used to be due date or undef. Now it is less straightforward returning am issue object if an issue row is created or undef. If the issue is a renewal undef is returned. As that case was not handled properly it caused the server site to crash the listener causing a communications error on the client. Signed-off-by: Frederic Demians Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi (cherry picked from commit b4967bf0ed60c5cca0c7f60591d21d2919f477a1) Signed-off-by: Frédéric Demians (cherry picked from commit 374f5f4a38883d351d441412cfdf4785bbe7f4b6) Signed-off-by: Liz Rea --- C4/SIP/ILS/Transaction.pm | 20 ++++++++++++++++++++ C4/SIP/ILS/Transaction/Checkout.pm | 8 +------- C4/SIP/ILS/Transaction/Renew.pm | 6 +----- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/C4/SIP/ILS/Transaction.pm b/C4/SIP/ILS/Transaction.pm index 4e74e93788..c751125907 100644 --- a/C4/SIP/ILS/Transaction.pm +++ b/C4/SIP/ILS/Transaction.pm @@ -8,6 +8,8 @@ use Carp; use strict; use warnings; use C4::Context; +use C4::Circulation qw( GetItemIssue ); +use Koha::DateUtils; my %fields = ( ok => 0, @@ -35,6 +37,24 @@ sub new { return bless $self, $class; } +sub duedatefromissue { + my ($self, $iss, $itemnum) = @_; + my $due_dt; + if (defined $iss ) { + $due_dt = dt_from_string( $iss->date_due() ); + } # renew from AddIssue ?? + else { + # need to reread the issue to get due date + $iss = GetItemIssue($itemnum); + if ($iss && $iss->{date_due} ) { + $due_dt = dt_from_string( $iss->{date_due} ); + } + } + return $due_dt; +} + + + sub DESTROY { # be cool } diff --git a/C4/SIP/ILS/Transaction/Checkout.pm b/C4/SIP/ILS/Transaction/Checkout.pm index 2b41c13d69..f046b15ef2 100644 --- a/C4/SIP/ILS/Transaction/Checkout.pm +++ b/C4/SIP/ILS/Transaction/Checkout.pm @@ -140,14 +140,8 @@ sub do_checkout { # . "w/ \$borrower: " . Dumper($borrower) . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv); my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 ); - my $due_dt = dt_from_string( $issue->date_due() ); - if ($due_dt) { - $self->{due} = $due_dt->clone(); - } else { - $self->{due} = undef; - } + $self->{due} = $self->duedatefromissue($issue, $itemnumber); - #$self->{item}->due_date($due); $self->ok(1); return $self; } diff --git a/C4/SIP/ILS/Transaction/Renew.pm b/C4/SIP/ILS/Transaction/Renew.pm index e0f905b023..699f5663a4 100644 --- a/C4/SIP/ILS/Transaction/Renew.pm +++ b/C4/SIP/ILS/Transaction/Renew.pm @@ -45,12 +45,8 @@ sub do_renew_for { } if ($renewokay){ - $self->{due} = undef; my $issue = AddIssue( $borrower, $self->{item}->id, undef, 0 ); - my $due_date = dt_from_string( $issue->date_due() ); - if ($due_date) { - $self->{due} = $due_date; - } + $self->{due} = $self->duedatefromissue($issue, $self->{item}->{itemnumber}); $self->renewal_ok(1); } else { $renewerror=~s/on_reserve/Item unavailable due to outstanding holds/;