From 266faa54a04cc2dc6c38162970879d0bb4c064e1 Mon Sep 17 00:00:00 2001 From: colemanw Date: Fri, 4 Aug 2023 15:29:54 -0400 Subject: [PATCH] ActionSchedule - Filter out mappings from disabled components --- CRM/Core/BAO/ActionSchedule.php | 9 ++++++++- Civi/ActionSchedule/MappingBase.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index ae0783a7f1..668d894f77 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -34,7 +34,14 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule implements $event = \Civi::dispatcher() ->dispatch('civi.actionSchedule.getMappings', new MappingRegisterEvent()); - Civi::$statics[__CLASS__]['mappings'] = $event->getMappings(); + // Filter out mappings from disabled components. + // TODO: we could move the mapping classes into their respective + // component-extensions and this would happen automatically. + // Civi::$statics[__CLASS__]['mappings'] = $event->getMappings(); + $allEntities = \Civi\Api4\Entity::get(FALSE)->execute()->column('name'); + Civi::$statics[__CLASS__]['mappings'] = array_filter($event->getMappings(), function($mapping) use ($allEntities) { + return in_array($mapping->getEntityName(), $allEntities, TRUE); + }); } if (isset($filters['id'])) { CRM_Core_Error::deprecatedWarning('Use "getMapping" to retrieve a single mapping by id instead of passing a filter to "GetMappings".'); diff --git a/Civi/ActionSchedule/MappingBase.php b/Civi/ActionSchedule/MappingBase.php index f4d078333c..cf68b80e2b 100644 --- a/Civi/ActionSchedule/MappingBase.php +++ b/Civi/ActionSchedule/MappingBase.php @@ -56,7 +56,7 @@ abstract class MappingBase extends AutoSubscriber implements MappingInterface { } public function getLabel(): string { - return CoreUtil::getInfoItem($this->getEntityName(), 'title'); + return CoreUtil::getInfoItem($this->getEntityName(), 'title') ?: ts('Unknown'); } public static function getLimitToOptions(): array { -- 2.25.1