FIX: $conf must reflect enabled/disabled state of modules (#29126)

This commit is contained in:
Florian Mortgat 2024-04-05 16:36:02 +02:00 committed by GitHub
parent a9bfe73e1a
commit 8b00b89f9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -521,6 +521,17 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
// Return code
if (!$err) {
$this->db->commit();
// set $conf properties
$conf->global->{$this->const_name} = 1;
$moduleNameInConf = strtolower(preg_replace('/^MAIN_MODULE_/', '', $this->const_name));
// two exceptions to handle
if ($moduleNameInConf === 'propale') $moduleNameInConf = 'propal';
elseif ($moduleNameInConf === 'supplierproposal') $moduleNameInConf = 'supplier_proposal';
if (! isset($conf->{$moduleNameInConf})) {
$conf->{$moduleNameInConf} = (object) array('enabled' => 1);
}
return 1;
} else {
$this->db->rollback();
@ -539,6 +550,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
*/
protected function _remove($array_sql, $options = '')
{
global $conf;
// phpcs:enable
$err = 0;
@ -605,6 +617,15 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
// Return code
if (!$err) {
$this->db->commit();
// unset $conf properties
if (isset($conf->global->{$this->const_name})) unset($conf->global->{$this->const_name});
$moduleNameInConf = strtolower(preg_replace('/^MAIN_MODULE_/', '', $this->const_name));
// two exceptions to handle
if ($moduleNameInConf === 'propale') $moduleNameInConf = 'propal';
elseif ($moduleNameInConf === 'supplierproposal') $moduleNameInConf = 'supplier_proposal';
if (isset($conf->{$moduleNameInConf})) unset($conf->{$moduleNameInConf});
return 1;
} else {
$this->db->rollback();