Fix dev/core#4240 - Saving entityReference field value via API
authorColeman Watts <coleman@civicrm.org>
Sat, 15 Apr 2023 19:57:43 +0000 (15:57 -0400)
committerColeman Watts <coleman@civicrm.org>
Sat, 15 Apr 2023 19:57:43 +0000 (15:57 -0400)
CRM/Utils/Type.php

index d83fbbe83f20c845395d39808ca2145aefac3805..87087711d0828139e9174b7f23019503c432ecfb 100644 (file)
@@ -236,6 +236,7 @@ class CRM_Utils_Type {
       case 'Date':
       case 'Timestamp':
       case 'ContactReference':
+      case 'EntityReference':
       case 'MysqlOrderByDirection':
         $validatedData = self::validate($data, $type, $abort);
         if (isset($validatedData)) {
@@ -380,6 +381,7 @@ class CRM_Utils_Type {
       'Date',
       'Timestamp',
       'ContactReference',
+      'EntityReference',
       'MysqlColumnNameOrAlias',
       'MysqlOrderByDirection',
       'MysqlOrderBy',
@@ -435,12 +437,13 @@ class CRM_Utils_Type {
         break;
 
       case 'ContactReference':
+      case 'EntityReference':
         // null is valid
         if (strlen(trim($data)) == 0) {
           return trim($data);
         }
 
-        if (CRM_Utils_Rule::validContact($data)) {
+        if (CRM_Utils_Rule::positiveInteger($data)) {
           return (int) $data;
         }
         break;