From 8b91d8490c0813d8b0ebd056877ca97c37e284ba Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 5 May 2021 13:57:18 +1200 Subject: [PATCH] Only attempt to disable entity if v3 create+is_active is an option --- CRM/Core/ManagedEntities.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CRM/Core/ManagedEntities.php b/CRM/Core/ManagedEntities.php index f918bb0348..d35ef2d104 100644 --- a/CRM/Core/ManagedEntities.php +++ b/CRM/Core/ManagedEntities.php @@ -301,10 +301,17 @@ class CRM_Core_ManagedEntities { * inactive. * * @param CRM_Core_DAO_Managed $dao + * + * @throws \CiviCRM_API3_Exception */ - public function disableEntity($dao) { - // FIXME: if ($dao->entity_type supports is_active) { - if (TRUE) { + public function disableEntity($dao): void { + $actions = civicrm_api3($dao->entity_type, 'getactions', [])['values']; + $supportsDisable = FALSE; + if (in_array('create', $actions, TRUE) && in_array('getfields', $actions)) { + $fields = civicrm_api3($dao->entity_type, 'getfields', ['action' => 'create'])['values']; + $supportsDisable = array_key_exists('is_active', $fields); + } + if ($supportsDisable) { // FIXME cascading for payproc types? $params = [ 'version' => 3, -- 2.25.1