From 180b20a6b8594b9039f6787400fbc38964f67cff Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 16 Jan 2020 13:09:58 +0000 Subject: [PATCH] Bug 24377: Record passed branch if renewing via cron To test: 1 - Checkout an item with auto renewal set and eligible for auto renew 2 - Set no renewal before in the circ rules to 99 (something greater than the checkout period) 3 - perl misc/cronjobs/automatic_renewals.pl 4 - Check the statistics table, note the branch for renewal is null SELECT * FROM statistics WHERE itemnumber={itemnumber} AND type='RENEWAL' 5 - Apply patch 6 - Repeat 1-4 7 - Note the branch is set to the issuing branch Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Ed Veal Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit 723c72397f02c168ffe4f7615022ed0d9be7de49) Signed-off-by: Lucas Gass --- C4/Circulation.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 7d6be93dd3..2518d871c9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2964,10 +2964,9 @@ sub AddRenewal { ) { DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' }); } - - unless ( C4::Context->interface eq 'opac' ) { #if from opac we are obeying OpacRenewalBranch as calculated in opac-renew.pl - $branch = C4::Context->userenv ? C4::Context->userenv->{branch} : $branch; - } + unless ( C4::Context->interface eq 'opac' ) { #if from opac we are obeying OpacRenewalBranch as calculated in opac-renew.pl + $branch = ( C4::Context->userenv && defined C4::Context->userenv->{branch} ) ? C4::Context->userenv->{branch} : $branch; + } # Add the renewal to stats UpdateStats( -- 2.39.5