From 4d669903b2c8637f8112842d3e68789832e799a5 Mon Sep 17 00:00:00 2001 From: coldrunKacper Date: Wed, 25 May 2016 11:21:00 +0200 Subject: [PATCH] Implementing changes from pull request #8351 --- CRM/Core/Component.php | 6 +++++- CRM/Core/OptionValue.php | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Component.php b/CRM/Core/Component.php index 0cd76fef74..4c2ad4c518 100644 --- a/CRM/Core/Component.php +++ b/CRM/Core/Component.php @@ -95,7 +95,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 fc96a9b783..62ad707953 100644 --- a/CRM/Core/OptionValue.php +++ b/CRM/Core/OptionValue.php @@ -62,12 +62,15 @@ 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; @@ -115,6 +118,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