API3 error when processing an entity reference relationship custom field with multiple values
Overview
When a custom field is set up in our case on a relationship of type Entity Reference and allowing multiple values when displaying this field via a view using CiviCRM entity the display of the field reverted from using the Display Name of the contact to the contact id.
This behaviour appears to be a result of https://github.com/civicrm/civicrm-core/blob/0383d160661a8be66161b71a8bbdedbb83217a78/api/v3/utils.php#L1448
Which expects that for each custom field it will only get one value for contact id - however in this case it's getting passed an array.
Reproduction steps
Somewhat complicated.
- There is a strong probability that we could see these errors elsewhere - but I've not had time to figure out an easy set of steps to replicate yet. I would assume that setting up any custom field of type entity reference and having multiple values would probably cause problems here, as the issue steps from the utils function not the CiviCRM entity code.
- Create a custom field of type entity reference on a relationship - I've not tested other entities but assume it will be happening here as well. Make sure to allow multiple values.
- Create data for this custom field and include at least one row whereby there are multiple values.
- Create a view to display this data and see that it shows the contact id not the display name of the contacts.
Current behaviour
CiviCRM api3 utils function fails to retrieve display name but does populate the ids which CiviCRM Entity then displays.
Expected behaviour
We should see the display names returned. I'm unclear as to whether this should be as an array or some sort of separated string! Both seem to yield same result in CiviCRM entity - I'm putting up a PR for an array as this seems nicer.
Environment information
This behaviour was observed on CiviCRM 5.45.3 with CiviCRM Entity pulled from the github repo latest version.