From: Vangelis Pantazis Date: Mon, 14 Mar 2022 09:16:38 +0000 (+0000) Subject: Optimise isCustomDateField X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7d3553e2cc9bc259551954c3c8bf40c54a52e735;p=civicrm-core.git Optimise isCustomDateField --- diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index e69e958d3f..ce5ca8eebe 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -4762,19 +4762,20 @@ civicrm_relationship.start_date > {$today} * @param $fieldName * * @return bool - * @throws \CiviCRM_API3_Exception + * @throws Exception */ public static function isCustomDateField($fieldName) { if (($customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName)) == FALSE) { return FALSE; } try { - $customFieldDataType = civicrm_api3('CustomField', 'getvalue', ['id' => $customFieldID, 'return' => 'data_type']); + $customFieldData = CRM_Core_BAO_CustomField::getFieldObject($customFieldID); + $customFieldDataType = $customFieldData->data_type; if ('Date' == $customFieldDataType) { return TRUE; } } - catch (CiviCRM_API3_Exception $e) { + catch (Exception $e) { } return FALSE; }