From: Tim Otten Date: Sat, 22 Aug 2015 09:45:39 +0000 (-0700) Subject: CRM-16373 - Config - Remove `enableComponentIDs` X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3d31a5c6761c983f1b8fc4ba65e5b0db7ce29147;p=civicrm-core.git 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`). --- diff --git a/CRM/Core/BAO/ConfigSetting.php b/CRM/Core/BAO/ConfigSetting.php index 4b3a7e4e4d..646ac5ffd5 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -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); diff --git a/CRM/Core/Config/Variables.php b/CRM/Core/Config/Variables.php index 26df64b164..07d34def92 100644 --- a/CRM/Core/Config/Variables.php +++ b/CRM/Core/Config/Variables.php @@ -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? diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index b9bacb0ce9..5caf02ab0c 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -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 {