From 1a216186ff97c292ef6292cd98572015cc7c5a32 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 29 Jul 2021 11:28:38 +0200 Subject: [PATCH] Bug 28785: Add skip_version_check for checkauth We could have this patch but we also could decide to skip it. The idea is to avoid 2 checks of the version when we are coming from checkauth. Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/Auth.pm | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 4133a6ee17..284bc4ed90 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -867,7 +867,7 @@ sub checkauth { elsif ( $sessionID = $query->cookie("CGISESSID") ) { # assignment, not comparison my ( $return, $more_info ); ( $return, $session, $more_info ) = check_cookie_auth( $sessionID, $flags, - { remote_addr => $ENV{REMOTE_ADDR} } + { remote_addr => $ENV{REMOTE_ADDR}, skip_version_check => 1 } ); if ( $return eq 'ok' ) { @@ -1644,19 +1644,23 @@ sub check_cookie_auth { my $remote_addr = $params->{remote_addr} || $ENV{REMOTE_ADDR}; - unless ( C4::Context->preference('Version') ) { + my $skip_version_check = $params->{skip_version_check}; # Only for checkauth - # database has not been installed yet - return ( "maintenance", undef ); - } - my $kohaversion = Koha::version(); - $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/; - if ( C4::Context->preference('Version') < $kohaversion ) { + unless ( $skip_version_check ) { + unless ( C4::Context->preference('Version') ) { - # database in need of version update; assume that - # no API should be called while databsae is in - # this condition. - return ( "maintenance", undef ); + # database has not been installed yet + return ( "maintenance", undef ); + } + my $kohaversion = Koha::version(); + $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/; + if ( C4::Context->preference('Version') < $kohaversion ) { + + # database in need of version update; assume that + # no API should be called while databsae is in + # this condition. + return ( "maintenance", undef ); + } } # see if we have a valid session cookie already -- 2.39.5