From 9e6f782907fe8e6cc7d79429a1cb994fc7ed82f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Feb 2022 11:26:03 +0100 Subject: [PATCH] Clean code --- htdocs/core/class/events.class.php | 2 +- htdocs/core/lib/security2.lib.php | 3 ++- htdocs/main.inc.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 104f1567d44..63b5e5e494b 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -167,7 +167,7 @@ class Events // extends CommonObject $sql .= " '".$this->db->escape(getUserRemoteIP())."',"; $sql .= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').","; $sql .= " '".$this->db->idate($this->dateevent)."',"; - $sql .= " ".($user->id ? "'".$this->db->escape($user->id)."'" : 'NULL').","; + $sql .= " ".($user->id > 0 ? ((int) $user->id) : 'NULL').","; $sql .= " '".$this->db->escape(dol_trunc($this->description, 250))."',"; $sql .= " '".$this->db->escape(dol_getprefix())."'"; $sql .= ")"; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index a37a77712c3..e156c83b147 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -187,7 +187,8 @@ if (!function_exists('dol_loginfunction')) { $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; } - // Set cookie for timeout management + // Set cookie for timeout management. We set it as a cookie so we will be able to use it to set timeout on next page before the session start + // and the conf file is loaded. $prefix = dol_getprefix(''); $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8ddcce45285..88ed3a12f3a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -282,7 +282,7 @@ if (!empty($php_session_save_handler) && $php_session_save_handler == 'db') { // Init session. Name of session is specific to Dolibarr instance. // Must be done after the include of filefunc.inc.php so global variables of conf file are defined (like $dolibarr_main_instance_unique_id or $dolibarr_main_force_https). -// Note: the function dol_getprefix is defined into functions.lib.php but may have been defined to return a different key to manage another area to protect. +// Note: the function dol_getprefix() is defined into functions.lib.php but may have been defined to return a different key to manage another area to protect. $prefix = dol_getprefix(''); $sessionname = 'DOLSESSID_'.$prefix; $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix;