From: Coleman Watts Date: Thu, 14 Oct 2021 02:45:29 +0000 (-0400) Subject: APIv4 - Fix possible recursion during Entity::get() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2c30573378ce598e9319e62b24765887061627a1;p=civicrm-core.git APIv4 - Fix possible recursion during Entity::get() --- diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 790fe70b6a..fdf38a1816 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -68,14 +68,18 @@ class CRM_Contact_BAO_ContactType extends CRM_Contact_DAO_ContactType { */ public static function basicTypeInfo($includeInactive = FALSE) { $cacheKey = 'CRM_CT_BTI_' . (int) $includeInactive; - if (!Civi::cache('contactTypes')->has($cacheKey)) { - $contactType = ContactType::get(FALSE)->setSelect(['*'])->addWhere('parent_id', 'IS NULL'); + $contactTypes = Civi::cache('contactTypes')->get($cacheKey, []); + if (!$contactTypes) { + $query = CRM_Utils_SQL_Select::from('civicrm_contact_type') + ->where('parent_id IS NULL'); if ($includeInactive === FALSE) { - $contactType->addWhere('is_active', '=', 1); + $query->where('is_active = 1'); } - Civi::cache('contactTypes')->set($cacheKey, (array) $contactType->execute()->indexBy('name')); + $dao = CRM_Core_DAO::executeQuery($query->toSQL()); + $contactTypes = array_column($dao->fetchAll(), NULL, 'name'); + Civi::cache('contactTypes')->set($cacheKey, $contactTypes); } - return Civi::cache('contactTypes')->get($cacheKey); + return $contactTypes; } /**