SearchKit - Don't crash afforms with non-dao entities
authorcolemanw <coleman@civicrm.org>
Wed, 6 Sep 2023 20:42:48 +0000 (16:42 -0400)
committercolemanw <coleman@civicrm.org>
Wed, 6 Sep 2023 20:42:48 +0000 (16:42 -0400)
ext/search_kit/Civi/Search/Meta.php

index 40251f5010dbd76b6a232f7e975caab611fe172c..9fadf2364c8c746c98268cd3dcf312efcd6adcde 100644 (file)
@@ -29,8 +29,11 @@ class Meta {
    * @return array
    */
   public static function getCalcFields($apiEntity, $apiParams): array {
-    $calcFields = [];
     $api = \Civi\API\Request::create($apiEntity, 'get', $apiParams);
+    if (!is_a($api, '\Civi\Api4\Generic\DAOGetAction')) {
+      return [];
+    }
+    $calcFields = [];
     $selectQuery = new \Civi\Api4\Query\Api4SelectQuery($api);
     $joinMap = $joinCount = [];
     foreach ($apiParams['join'] ?? [] as $join) {