Commit 3d31a5c6 authored by totten's avatar totten

CRM-16373 - Config - Remove `enableComponentIDs`

Note: `enableComponents` is heavily used, but `enableComponentIDs` is only
used once.  Generally, it's much easier to write tests based on names
(`enableComponents`) than IDs (`enableComponentIDs`).
parent 40787e18
......@@ -322,15 +322,6 @@ class CRM_Core_BAO_ConfigSetting {
$enableComponents = Civi::settings()->get('enable_components');
if (!empty($enableComponents)) {
$defaults['enableComponents'] = $enableComponents;
// Lookup component IDs. Note: Do *not* instantiate components.
// Classloading may not be fully setup yet.
$components = CRM_Core_Component::getComponentIDs();
$enabledComponentIDs = array();
foreach ($defaults['enableComponents'] as $name) {
$enabledComponentIDs[] = $components[$name];
}
$defaults['enableComponentIDs'] = $enabledComponentIDs;
}
}
}
......@@ -689,16 +680,9 @@ WHERE option_group_id = (
*/
public static function setEnabledComponents($enabledComponents) {
$config = CRM_Core_Config::singleton();
$components = CRM_Core_Component::getComponents();
$enabledComponentIDs = array();
foreach ($enabledComponents as $name) {
$enabledComponentIDs[] = $components[$name]->componentID;
}
// fix the config object
$config->enableComponents = $enabledComponents;
$config->enableComponentIDs = $enabledComponentIDs;
// also force reset of component array
CRM_Core_Component::getEnabledComponents(TRUE);
......
......@@ -324,7 +324,6 @@ class CRM_Core_Config_Variables extends CRM_Core_Config_Defaults {
'CiviMail',
'CiviReport',
);
public $enableComponentIDs = array(1, 6, 2, 3, 4, 8);
/**
* Should payments be accepted only via SSL?
......
......@@ -508,13 +508,14 @@ class CRM_Core_Permission {
}
// if component_id is present, ensure it is enabled
if (isset($item['component_id']) &&
$item['component_id']
) {
if (isset($item['component_id']) && $item['component_id']) {
if (!isset(Civi::$statics[__CLASS__]['componentNameId'])) {
Civi::$statics[__CLASS__]['componentNameId'] = array_flip(CRM_Core_Component::getComponentIDs());
}
$componentName = Civi::$statics[__CLASS__]['componentNameId'][$item['component_id']];
$config = CRM_Core_Config::singleton();
if (is_array($config->enableComponentIDs) &&
in_array($item['component_id'], $config->enableComponentIDs)
) {
if (is_array($config->enableComponents) && in_array($componentName, $config->enableComponents)) {
// continue with process
}
else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment