Problem/Motivation
When I push an entity through the salesforce push UI, the following warning appears:
addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated
Steps to reproduce
- Create a Salesforce mapping with Salesforce for a specific entity. Activate queue option.
- Create an entity related to the configuration created before.
- Go to the 'Salesforce' tab.
- Push it.
After this, the warning appears.
It only happens the first time, when the entity is not pushed yet to salesforce.
Proposed resolution
Error comes from UniqueFieldsConstraintValidator, which prevents creating duplicated entities according to the unique fields configured. The warning occurs because the query to find entities with the same unique fields is filtering by NULL values when field values are empty.
Proposed resolution is preventing the query filtering by NULL values.
Comments
Comment #2
omarlopesinoComment #3
omarlopesinoComment #4
omarlopesinoI was thinking this problem can be solved by just passing an empty string when the values are empty. But does it make sense finding a unique entity if one of the unique fields is empty? Should not we filter only if all unique fields are present?
Comment #5
aaronbaumanThe unique fields constraint checks to make sure that a mapped object doesn't already exist.
If one of the identifiers is empty, it's probably too early to be checking that constraint.
So I think we can skip the check altogether if that's the case.