Merge branch '4531-8567-No-está-funcionando-bien-el-cierre-de-sessiones' into 'develop'

Fixed session garbage collector

See merge request artica/pandorafms!2685
This commit is contained in:
Alejandro Fraguas 2019-08-28 12:54:40 +02:00
commit 14bf71e6c6
3 changed files with 27 additions and 3 deletions

View File

@ -1243,7 +1243,7 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned;
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 30);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 31);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png');

View File

@ -159,7 +159,26 @@ function pandora_session_gc($max_lifetime=300)
global $config;
if (isset($config['session_timeout'])) {
$max_lifetime = $config['session_timeout'];
$session_timeout = $config['session_timeout'];
} else {
// if $config doesn`t work ...
$session_timeout = db_get_value(
'value',
'tconfig',
'token',
'session_timeout'
);
}
if (!empty($session_timeout)) {
if ($session_timeout == -1) {
// The session expires in 10 years
$session_timeout = 315576000;
} else {
$session_timeout *= 60;
}
$max_lifetime = $session_timeout;
}
$time_limit = (time() - $max_lifetime);
@ -171,6 +190,11 @@ function pandora_session_gc($max_lifetime=300)
]
);
// Deleting cron and empty sessions.
$sql = "DELETE FROM tsessions_php WHERE
data IS NULL OR id_session REGEXP '^cron-'";
db_process_sql($sql);
return $retval;
}

View File

@ -109,7 +109,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('custom_report_front_logo', 'images/pandora_logo_white.jpg'),
('custom_report_front_header', ''),
('custom_report_front_footer', ''),
('MR', 30),
('MR', 31),
('identification_reminder', 1),
('identification_reminder_timestamp', 0),
('current_package_enterprise', '738'),