pimcore / customer-data-framework

Customer Data Framework community bundle adds capability for management of customer data to Pimcore.
https://pimcore.com/docs/platform/Customer_Management_Framework/
Other
81 stars 93 forks source link

[Bug]: On PHP8, deprecation warning occurs when trim() function is called with a null parameter #542

Open lasso opened 2 weeks ago

lasso commented 2 weeks ago

Expected behavior

trim() function should not be called with null parameter.

Actual behavior

In src/DuplicatesIndex/DefaultMariaDbDuplicatesIndex.php, line 699 the trim() function gets called without ensuring that the value is not null. Before PHP8 this was not a problem, put in PHP8 this raises a deprecation warning:

<b>Deprecated</b>: trim(): Passing null to parameter #1 ($string) of type string is deprecated in <b>/var/www/pimcore/vendor/pimcore/customer-management-framework-bundle/src/Dupl
icatesIndex/DefaultMariaDbDuplicatesIndex.php</b> on line <b>699</b><br />

If error_reporting is set to E_ALL, this will mess up the response sent to the client.

Steps to reproduce

Sorry, even though I was a PHP developer a long time ago, I'm not a regular Pimcore developer/user. While helping a customer, I found this error tainting a JSON response and decided to find out where it came from. I guess a prerequisite would be that at least one of the fields in the index must be null, but beyond that I don't have any more information.