Problem/Motivation

Null values no longer allowed as first parameter to substr. "$value = substr($value, 0, 19);" in "pullValue" does not check for null.

Steps to reproduce

Create a mapping that pulls a date value from SF. Attempt pulling a null value for that date on a site running PHP 8.1. Observe PHP warning in watchdog: Deprecated function: substr(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase->pullValue() (line 285 of /code/web/modules/contrib/salesforce/modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php)

Proposed resolution

Ensure that first param is a string prior to calling substr

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Comments

sean_fremouw created an issue. See original summary.

sean_fremouw’s picture

StatusFileSize
new681 bytes

Initial proposed patch

sean_fremouw’s picture

Issue summary: View changes
capysara’s picture

Status: Active » Needs review

I haven't manually tested this, but code looks good. This update will prevent substr from being called if there is no $value.

aaronbauman’s picture

Status: Needs review » Fixed

committed, thanks for the patch

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.