- Issue created by @scambler
- Status changed to Needs review
4 months ago 11:11am 26 July 2024
drupal/core-recommended: 10.0.11
drupal/salesforce: 5.0.4
I am getting an unexpected type error at L253 of SalesforceMappingFieldPluginBase.php: https://git.drupalcode.org/project/salesforce/-/blob/5.0.4/modules/sales...
if (!empty($value) && $field_definition['length'] > 0 && mb_strlen($value) > $field_definition['length']) {
$value = mb_substr($value, 0, $field_definition['length']);
}
This will result in an unexpected type error, as mb_strlen() expects a string, but the value is an array.
Add an is_string() check to L253, or convert all arrays to strings. I have opted for the latter in my patch, as it seems the expected value should always be a string.
It might also be helpful to add an optional $value parameter to the pushValue function and use it if not empty. This way child classes can alter the value before running the parent class.
Someone more familiar with the code to review and improve my patch as it feels too straightforward.
Needs review
5.0
salesforce_mapping.module