From d5d221160184120140950112ef8edfb0ea476949 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 31 Jul 2020 09:49:06 +0200 Subject: [PATCH] Bug 26108: (bug 25855 follow-up) Call after_circ_action hook only if issue exists AddReturn can be called on an item even if it's not checked out (to trigger holds for instance). The hook should (?) not be called in that situation Test plan: Confirm the above and that the following tests are now passing: t/db_dependent/SIP/Message.t t/db_dependent/Reserves.t t/db_dependent/Circulation/issue.t t/db_dependent/SIP/Transaction.t t/db_dependent/Circulation.t Signed-off-by: Jonathan Druart --- C4/Circulation.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index bda4b00490..4b468f80f8 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2206,14 +2206,16 @@ sub AddReturn { } } - my $checkin = Koha::Old::Checkouts->find($issue->id); + if ( $issue ) { + my $checkin = Koha::Old::Checkouts->find($issue->id); - Koha::Plugins->call('after_circ_action', { - action => 'checkin', - payload => { - checkout=> $checkin - } - }); + Koha::Plugins->call('after_circ_action', { + action => 'checkin', + payload => { + checkout=> $checkin + } + }); + } return ( $doreturn, $messages, $issue, ( $patron ? $patron->unblessed : {} )); } -- 2.39.5