From a29fa784c32ff10dba0c7b27689eb7646bd72a4e Mon Sep 17 00:00:00 2001 From: coldrunKacper Date: Wed, 11 May 2016 15:09:13 +0200 Subject: [PATCH] CiviCRM 4.6 - 'Components inside disabled Extensions' issue fix. --- CRM/Core/Component.php | 6 +++++- CRM/Core/OptionValue.php | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CRM/Core/Component.php b/CRM/Core/Component.php index da70a18ef1..70a463d8d1 100644 --- a/CRM/Core/Component.php +++ b/CRM/Core/Component.php @@ -99,7 +99,11 @@ class CRM_Core_Component { $cr->find(FALSE); while ($cr->fetch()) { $infoClass = $cr->namespace . '_' . self::COMPONENT_INFO_CLASS; - require_once str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php'; + $infoClassFile = str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php'; + if (!CRM_Utils_File::isIncludable($infoClassFile)) { + continue; + } + require_once $infoClassFile; $infoObject = new $infoClass($cr->name, $cr->namespace, $cr->id); if ($infoObject->info['name'] !== $cr->name) { CRM_Core_Error::fatal("There is a discrepancy between name in component registry and in info file ({$cr->name})."); diff --git a/CRM/Core/OptionValue.php b/CRM/Core/OptionValue.php index 82c40570e7..9226895247 100644 --- a/CRM/Core/OptionValue.php +++ b/CRM/Core/OptionValue.php @@ -64,12 +64,14 @@ class CRM_Core_OptionValue { * Has links like edit, delete, disable ..etc. * @param string $orderBy * For orderBy clause. - * + * @param bool $skipEmptyComponents + * Whether to skip OptionValue rows with empty Component name + * (i.e. when Extension providing the Component is disabled) * @return array * Array of option-values * */ - public static function getRows($groupParams, $links, $orderBy = 'weight') { + public static function getRows($groupParams, $links, $orderBy = 'weight', $skipEmptyComponents = TRUE) { $optionValue = array(); $optionGroupID = NULL; @@ -117,6 +119,13 @@ class CRM_Core_OptionValue { while ($dao->fetch()) { $optionValue[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $optionValue[$dao->id]); + if (!empty($optionValue[$dao->id]['component_id']) && + empty($componentNames[$optionValue[$dao->id]['component_id']]) && + $skipEmptyComponents + ) { + unset($optionValue[$dao->id]); + continue; + } // form all action links $action = array_sum(array_keys($links)); -- 2.25.1