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

Issue fork salesforce-3222940

Command icon 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

lucastockmann created an issue. See original summary.

lucastockmann’s picture

Status: Active » Needs review
StatusFileSize
new995 bytes

Patch against 8.x-4.x

lucastockmann’s picture

aaronbauman’s picture

Status: Needs review » Fixed

Great, thanks for the patch.

Status: Fixed » Closed (fixed)

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