diff --git a/ext/search_kit/Civi/Search/Admin.php b/ext/search_kit/Civi/Search/Admin.php index 0f74b1f740ec..ee85568afd35 100644 --- a/ext/search_kit/Civi/Search/Admin.php +++ b/ext/search_kit/Civi/Search/Admin.php @@ -12,6 +12,7 @@ namespace Civi\Search; use Civi\Api4\Action\SearchDisplay\AbstractRunAction; +use Civi\Api4\Entity; use Civi\Api4\Extension; use Civi\Api4\Query\SqlEquation; use Civi\Api4\Query\SqlFunction; @@ -30,6 +31,7 @@ class Admin { * Returns clientside data needed for the `crmSearchAdmin` Angular module. * * @return array + * @throws \CRM_Core_Exception */ public static function getAdminSettings():array { $schema = self::getSchema(); @@ -119,10 +121,11 @@ public static function getStyles():array { * Fetch all entities the current user has permission to `get`. * * @return array[] + * @throws \CRM_Core_Exception */ public static function getSchema(): array { $schema = []; - $entities = \Civi\Api4\Entity::get() + $entities = Entity::get() ->addSelect('name', 'title', 'title_plural', 'bridge_title', 'type', 'primary_key', 'description', 'label_field', 'icon', 'dao', 'bridge', 'ui_join_filters', 'searchable', 'order_by') ->addWhere('searchable', '!=', 'none') ->addOrderBy('title_plural') @@ -141,11 +144,17 @@ public static function getSchema(): array { if (!empty($paths['add'])) { $entity['addPath'] = $paths['add']; } - $getFields = civicrm_api4($entity['name'], 'getFields', [ - 'select' => ['name', 'title', 'label', 'description', 'type', 'options', 'input_type', 'input_attrs', 'data_type', 'serialize', 'entity', 'fk_entity', 'readonly', 'operators', 'suffixes', 'nullable'], - 'where' => [['deprecated', '=', FALSE], ['name', 'NOT IN', ['api_key', 'hash']]], - 'orderBy' => ['label'], - ]); + try { + $getFields = civicrm_api4($entity['name'], 'getFields', [ + 'select' => ['name', 'title', 'label', 'description', 'type', 'options', 'input_type', 'input_attrs', 'data_type', 'serialize', 'entity', 'fk_entity', 'readonly', 'operators', 'suffixes', 'nullable'], + 'where' => [['deprecated', '=', FALSE], ['name', 'NOT IN', ['api_key', 'hash']]], + 'orderBy' => ['label'], + ]); + } + catch (\CRM_Core_Exception $e) { + \Civi::log()->warning('Entity could not be loaded', ['entity' => $entity['name']]); + continue; + } foreach ($getFields as $field) { $field['fieldName'] = $field['name']; // Hack for RelationshipCache to make Relationship fields editable @@ -408,7 +417,11 @@ private static function getJoinConditions(string $nearCol, string $farCol, strin * * @param string $alias * @param array ...$entities + * * @return array + * + * @throws \CRM_Core_Exception + * @throws \Civi\API\Exception\NotImplementedException */ private static function getJoinDefaults(string $alias, ...$entities):array { $conditions = [];