Problem/Motivation
We created some mapping settings an when editing we get a php notice:
Notice: Undefined index: last_pull_timestamp in Drupal\salesforce_mapping\Entity\SalesforceMapping->getLastPullTime() (line 582 of modules/contrib/salesforce/modules/salesforce_mapping/src/Entity/SalesforceMapping.php).
This is caused by some shorthand if statements whom are not checking if given array key is set.
Steps to reproduce
Proposed resolution
Instead of doing this:
return $this->pull_info['last_delete_timestamp'] ? $this->pull_info['last_delete_timestamp'] : NULL;
We should do this:
return !isset($this->pull_info['last_delete_timestamp']) ? $this->pull_info['last_delete_timestamp'] : NULL;
Or even better this:
return $this->pull_info['last_delete_timestamp'] ?? NULL;
Null coalesce operator was introduced in PHP 7.0 and therefore is ok to be used in Drupal 8 modules.
https://www.php.net/manual/de/migration70.new-features.php#migration70.n...
https://www.drupal.org/docs/system-requirements/php-requirements
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | salesforce-use_null_coalesce_operator-3222940-2.patch | 995 bytes | lucastockmann |
Issue fork salesforce-3222940
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lucastockmann commentedPatch against 8.x-4.x
Comment #4
lucastockmann commentedMerge Request filed https://git.drupalcode.org/project/salesforce/-/merge_requests/22
Comment #6
aaronbaumanGreat, thanks for the patch.