EntityRef to Contact throws fatal error
Overview
In testing PR 25927, I ran into an error specially when the Entity being referenced is Contact. While you can create the custom field, when you try to add a value to that EntityRef, say on a Contribution, and submit it, a fatal error is thrown.
Reproduction steps
Note that I'm using a custom group to be used on Contributions
- Create a custom field of type EntityRef and select Contact as the Entity
- Click Contributions > New Contribution
- Fill out the Contribution required fields, and select a Contact for the EntityRef custom field
- Click Save
- Got an error: "One of parameters (value: ) is not of the type Integer".
Current behaviour
A user cannot actually use a created EntityRef custom field if the entity being referenced is a Contact. Note that this behavior does not happen with other entities, such as Event or Activity
Expected behaviour
A user should be able to used EntityRef custom field to a Contact without a fatal error.
Environment information
- CiviCRM: _Master/5.61.alpha1
Comments
Error details and backtrace from the ConfigAndLog file
$Fatal Error Details = array:3 [
"message" => "One of parameters (value: ) is not of the type Integer"
"code" => null
"exception" => CRM_Core_Exception {#1848
-errorData: array:1 [
"error_code" => 0
]
#cause: null
-_trace: null
#message: "One of parameters (value: ) is not of the type Integer"
#code: 0
#file: "/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Utils/Type.php"
#line: 471
trace: {
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Utils/Type.php:471 {
› $data = htmlentities($data ?? 'NULL');
› throw new CRM_Core_Exception("$name (value: $data) is not of the type $type");
› }
}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/DAO.php:1763 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/DAO.php:1643 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php:275 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php:403 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Contribute/BAO/Contribution.php:233 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Contribute/BAO/Contribution.php:481 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Contribute/Form/Contribution.php:1792 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Contribute/Form/Contribution.php:976 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/Form.php:578 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php:153 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php:120 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php:203 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php:103 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/Controller.php:355 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Contribute/Page/Tab.php:409 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Contribute/Page/Tab.php:463 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/Invoke.php:319 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/Invoke.php:69 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/CRM/Core/Invoke.php:36 { …}
/buildkit/build/dmain/web/sites/all/modules/civicrm/drupal/civicrm.module:471 { …}
/buildkit/build/dmain/web/includes/menu.inc:527 { …}
/buildkit/build/dmain/web/index.php:21 { …}
}
}
]