From e26ed87dbb21c1bf1c445fd55a6926338577cb9d 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. --- C4/Auth.pm | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 96a5c996b42..a8483b87c58 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -871,7 +871,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' ) { @@ -1648,19 +1648,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.20.1