Problem/Motivation

PHP 8 started marking as deprecated passing a null parameter where a string is expected. This caused the following warning:

Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase->pushValue() (line 243 of modules/contrib/salesforce/modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php).

Steps to reproduce

I'm not sure how to produce this on a vanilla site. It's reproducible on the client's site by logging in with one of the user fields empty.

Proposed resolution

Check for empty before sending to strlen().

Remaining tasks

Test patch.

User interface changes

API changes

Data model changes

None of these are affected.

Comments

Michelle created an issue. See original summary.

michelle’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new732 bytes
vmarchuk’s picture

@Michelle
The patch from comment #2 works fine. Thanks!

manuvelasco’s picture

The patch from #2 works fine.

capysara’s picture

I am using Salesforce with webform, pushing to SF to create objects when a webform is submitted. I submitted some webforms to Drupal, but they were not successfully pushed to SF. I made some changes to the mapping configuration and then ran cron. Cron successfully pushed to Salesforce, but this deprecation warning would display.

Using Salesforce 5.0.0, Drupal 9.4.7, and php 8.1.10, patch applies cleanly and I no longer get the php warning.

capysara’s picture

Status: Needs review » Reviewed & tested by the community

  • AaronBauman committed 582f757 on 5.0.x
    Issue #3304404 by Michelle: Null $value causing PHP 8 deprecation...
aaronbauman’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks for the patch!

Status: Fixed » Closed (fixed)

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