From 6b7de51d213f1ce016aa13950149b02827c85592 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Apr 2023 01:52:35 +0200 Subject: [PATCH] Work on PHP 8 compatibility --- htdocs/core/class/conf.class.php | 3 ++- htdocs/core/lib/functions.lib.php | 4 +++- htdocs/install/inc.php | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d70de618be8..01cdfde69fe 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -358,11 +358,12 @@ class Conf if ($modulename == 'supplierproposal') { $modulename = 'supplier_proposal'; } + $this->modules[$modulename] = $modulename; // Add this module in list of enabled modules + // deprecated if (!isset($this->$modulename) || !is_object($this->$modulename)) { $this->$modulename = new stdClass(); } $this->$modulename->enabled = true; - $this->modules[] = $modulename; // Add this module in list of enabled modules } } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 82644198aa3..a139a66c286 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -166,7 +166,9 @@ function getDolUserInt($key, $default = 0, $tmpuser = null) function isModEnabled($module) { global $conf; - return !empty($conf->$module->enabled); + + return !empty($conf->modules[$module]); + //return !empty($conf->$module->enabled); } /** diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 636f365683f..c0bded73cd2 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -323,6 +323,7 @@ if (!isset($conf->syslog) || !is_object($conf->syslog)) { $conf->syslog = new stdClass(); } $conf->syslog->enabled = 1; +$conf->modules['syslog'] = 'syslog'; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); @@ -435,6 +436,7 @@ function conf($dolibarr_main_document_root) $conf->syslog = new stdClass(); } $conf->syslog->enabled = 1; + $conf->modules['syslog'] = 'syslog'; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { define('SYSLOG_HANDLERS', '["mod_syslog_file"]');