Merge branch 'ent-6791-sesiones-se-borran-con-pandora_db' into 'develop'

Avoid erase ALL sessions from tsessions_php (pandora_db)

See merge request artica/pandorafms!3663
This commit is contained in:
Daniel Rodriguez 2021-01-05 13:43:42 +01:00
commit 40921b96f9
2 changed files with 25 additions and 12 deletions

View File

@ -727,6 +727,14 @@ function config_update_config()
if (!config_update_value('session_timeout', get_parameter('session_timeout'))) {
$error_update[] = __('Session timeout');
} else {
if ((int) get_parameter('session_timeout') === 0) {
$error_update[] = __('Session timeout forced to 90 minutes');
if (!config_update_value('session_timeout', 90)) {
$error_update[] = __('Session timeout');
}
}
}
if (isset($config['fallback_local_auth']) && $config['fallback_local_auth'] == 0) {

View File

@ -971,7 +971,14 @@ sub pandora_delete_old_session_data {
my $session_timeout = $conf->{'_session_timeout'};
if ($session_timeout ne '') {
# DO not erase anything if session_timeout is not set.
return unless (defined($session_timeout) && $session_timeout ne '');
if ($session_timeout == 0) {
# As defined in console.
$session_timeout = 90;
}
if ($session_timeout == -1) {
# The session expires in 10 years
$session_timeout = 315576000;
@ -980,15 +987,13 @@ sub pandora_delete_old_session_data {
}
$ulimit_timestamp = time() - $session_timeout;
}
log_message ('PURGE', "Deleting old session data from tsessions_php\n");
while(db_delete_limit ($dbh, 'tsessions_php', 'last_active < ?', $SMALL_OPERATION_STEP, $ulimit_timestamp) ne '0E0') {
usleep (10000);
};
db_do ($dbh, "DELETE FROM tsessions_php WHERE
data IS NULL OR id_session REGEXP '^cron-'");
db_do ($dbh, "DELETE FROM tsessions_php WHERE data IS NULL OR id_session REGEXP '^cron-'");
}
###############################################################################