From ce441708906fa282e000f523243ded20541970cc Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 31 Jul 2020 09:52:10 -0300 Subject: [PATCH] Bug 26108: Only call the plugin hook if a return took place This patch makes the hooks be called only if the checkin is effective (i.e. if it is not rejected for some reason. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Plugins/Circulation_hooks.t => FAIL: Tests fail 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- C4/Circulation.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 4b468f80f8..a9cf02ca3d 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2124,7 +2124,7 @@ sub AddReturn { my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->itemnumber, undef, $lookahead ) unless ( $item->withdrawn ); # if a hold is found and is waiting at another branch, change the priority back to 1 and trigger the hold (this will trigger a transfer and update the hold status properly) - if ( $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) { + if ( $resfound and $resfound eq "Waiting" and $branch ne $resrec->{branchcode} ) { my $hold = C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } ); $resfound = 'Reserved'; $resrec = $hold->unblessed; @@ -2206,7 +2206,7 @@ sub AddReturn { } } - if ( $issue ) { + if ( $doreturn and $issue ) { my $checkin = Koha::Old::Checkouts->find($issue->id); Koha::Plugins->call('after_circ_action', { -- 2.39.5