Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.7.24
-
Fix Version/s: 4.7.27
-
Component/s: CiviCRM API
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Contributed Code
-
Verified?:No
Description
This is kinda obscure but it's legit for the components of a display name to add up to more than the display name allows (128) char.
For example
civicrm_api3('Contact', 'create', array(
'first_name' => str_pad('a', 64, 'a'),
'last_name' => str_pad('a', 64, 'a'),
));
will give a fatal error as 64 + 64 +1 (the space) is more than the number of chars allowed.
I don't think we should give a hard error on a calculated field being too long & believe a truncate is fine - ie
if (strlen($contact->display_name) > 128) {
$contact->display_name = substr($contact->display_name, 128);
}
if (strlen($contact->sort_name) > 128) {
$contact->sort_name = substr($contact->sort_name, 128);
}