Optimise isCustomDateField
authorVangelis Pantazis <v.pantazis@ixiam.com>
Mon, 14 Mar 2022 09:16:38 +0000 (09:16 +0000)
committerVangelis Pantazis <v.pantazis@ixiam.com>
Mon, 14 Mar 2022 09:16:38 +0000 (09:16 +0000)
CRM/Contact/BAO/Query.php

index e69e958d3f989b60a70f45c0447966ab32ccc36f..ce5ca8eebec0d7910325a0b87b863a4b5342122e 100644 (file)
@@ -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;
   }