Prevent hard error when a string is too long for a field.
authoreileen <emcnaughton@wikimedia.org>
Fri, 26 Oct 2018 00:57:48 +0000 (13:57 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 26 Oct 2018 00:59:42 +0000 (13:59 +1300)
commit809e1a833f58c1e595f73dcd1f9101e2179caa8a
treea1ac2279f8ebb456ac1e38160172e5fd3b9450e8
parentb965352de26b6956a271cacff3124f9d3074a52a
Prevent hard error when a string is too long for a field.

Over time we have had various requests to extend the length of various
fields (currently https://github.com/civicrm/civicrm-core/pull/12939 ).

The main issue is not that it matters to capture every single character of
a crazy long user entered field - but that a hard fail when the data is too long can lose payment or registration or other data & provide a bad
experience.

This PR makes it still save, with a logged message & the utf friendly
function in play. As of writing the api validation is stilltight - see
```
  // Check our field length
    throw new API_Exception("Value for $fieldName is " . strlen(utf8_decode($value)) . " characters  - This field has a maxlength of {$fieldInfo['maxlength']} characters.",
      2100, array('field' => $fieldName)
    );
  }
```
and changing this is up for discussion.

Note that at the UI level max field lengths can be enforced by using
addField which uses metadata to determine field length etc
CRM/Core/DAO.php
tests/phpunit/api/v3/ParticipantTest.php