From 160ed321bee5806d9f58b064a27b1c31c9ae3fe4 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 2 May 2014 20:25:22 +0000 Subject: [PATCH] Bug 11182: (follow-up) fix regression where session branch wasn't initialized C4::Context->userenv() won't return a valid value until the user session set up, e.g., via get_template_and_user(). Consequently, the change introduced by a previous commit for bug 11182 ended up making it appear that when checking an item that fills a hold that it always needs to be transferred. This patch fixes the regression and moves the "no-branch-set" check to where it belongs. Signed-off-by: Galen Charlton --- circ/returns.pl | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/circ/returns.pl b/circ/returns.pl index cb5ccf1199..55888a6988 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -49,17 +49,6 @@ use Koha::Calendar; my $query = new CGI; -my $userenv = C4::Context->userenv; -if (!$userenv){ - my $sessionID = $query->cookie("CGISESSID"); - my $session = get_session($sessionID); - if ($session->param('branch') eq 'NO_LIBRARY_SET'){ - # no branch set we can't return - print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl"); - exit; - } -} - #getting the template my ( $template, $librarian, $cookie ) = get_template_and_user( { @@ -71,10 +60,19 @@ my ( $template, $librarian, $cookie ) = get_template_and_user( } ); +my $sessionID = $query->cookie("CGISESSID"); +my $session = get_session($sessionID); +if ($session->param('branch') eq 'NO_LIBRARY_SET'){ + # no branch set we can't return + print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl"); + exit; +} + ##################### #Global vars my $branches = GetBranches(); my $printers = GetPrinters(); +my $userenv = C4::Context->userenv; my $userenv_branch = $userenv->{'branch'} // ''; my $printer = $userenv->{'branchprinter'} // ''; -- 2.39.5