From 2af581331027784a3537d84439f2c32436b0e1c7 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Tue, 2 Oct 2012 13:49:32 +0200 Subject: [PATCH] Bug 8497: Strange behavior when modifying the timeout system preference Signed-off-by: Owen Leonard Tested standard login, patron auto-complete, and system preferences. Signed-off-by: Paul Poulain Signed-off-by: Chris Cormack Signed-off-by: Jared Camins-Esakov --- C4/Auth.pm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index a8ef09f7ce..f9213f2ab7 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -629,6 +629,15 @@ sub _session_log { close L; } +sub _timeout_syspref { + my $timeout = C4::Context->preference('timeout') || 600; + # value in days, convert in seconds + if ($timeout =~ /(\d+)[dD]/) { + $timeout = $1 * 86400; + }; + return $timeout; +} + sub checkauth { my $query = shift; $debug and warn "Checking Auth"; @@ -639,12 +648,7 @@ sub checkauth { $type = 'opac' unless $type; my $dbh = C4::Context->dbh; - my $timeout = C4::Context->preference('timeout'); - # days - if ($timeout =~ /(\d+)[dD]/) { - $timeout = $1 * 86400; - }; - $timeout = 600 unless $timeout; + my $timeout = _timeout_syspref(); _version_check($type,$query); # state variables @@ -1086,8 +1090,7 @@ sub check_api_auth { my $flagsrequired = shift; my $dbh = C4::Context->dbh; - my $timeout = C4::Context->preference('timeout'); - $timeout = 600 unless $timeout; + my $timeout = _timeout_syspref(); unless (C4::Context->preference('Version')) { # database has not been installed yet @@ -1319,8 +1322,7 @@ sub check_cookie_auth { my $flagsrequired = shift; my $dbh = C4::Context->dbh; - my $timeout = C4::Context->preference('timeout'); - $timeout = 600 unless $timeout; + my $timeout = _timeout_syspref(); unless (C4::Context->preference('Version')) { # database has not been installed yet -- 2.39.5