PHP fatal when importing mapping config deletions

Created on 13 September 2023, over 1 year ago
Updated 14 November 2023, about 1 year ago

Problem/Motivation

Importing a deletion of a mapping config results in a PHP fatal error.

Steps to reproduce

Create a mapping configuration, using the UI at admin/config/services/gathercontent/mapping.
Export the mapping into the site's config directory. This will include the mapping config as well as a migrate_plus migration config.
Deploy that change to a second environment and import config there.
Delete the mapping that was just created, using the same UI as before.
Export the mapping change into the site's config directory. This will remove the mapping config, and will remove the migrate_plus migration config.
Deploy that change to the same second environment as before, and import config there.
A PHP fatal error will be seen.

Error: Call to a member function delete() on null in /var/www/docroot/modules/contrib/gathercontent/src/Entity/Mapping.php on line 349 #0 /var/www/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(460): Drupal\gathercontent\Entity\Mapping::postDelete(Object(Drupal\Core\Config\Entity\ConfigEntityStorage), Array)

Proposed resolution

Check for a loaded migration object before calling methods on it, specifically in Drupal\gathercontent\Entity\Mapping::postDelete

Remaining tasks

Update the code to avoid the error.

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

🇺🇸United States nadavoid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024