Provide a way to unset empty Migrate Row destinations

Created on 3 May 2022, over 2 years ago
Updated 12 January 2024, 12 months ago

Problem/Motivation

Currently some non-one-to-one Drupal migrations can result in empty destination properties of really important fields e.g. ID.

e.g. doing a migration lookup against the primary ID, and returning a NULL would result in the ID being set as an "empty property", and subsequently set to NULL everytime the Migration entity is updated as part of the migration, which might not necessarily be the expected behaviour especially for Migration stubs.

And there's currently no way for process plugins to remove empty properties.

Steps to reproduce

Provide a migration which does a lookup against the exisiting ID in some way in order to detect uniqueness, if the lookup fails, the ID will always be set to NULL.

Proposed resolution

Provide API that allows pre row save hooks to easily stop certain important properties from being explicitly flagged as NULL.

Or provide a plugin property/API which can be used to skip the setEmptyDestinationProperty behaviour similar to the $plugin->multiple(); method.

Or we could explicitly ignore IDs and other special fields from being flagged as "empty destinations" (unsure what consequences this might have).

Remaining tasks

Provide issue fork/patch with tests.

User interface changes

N/A

API changes

Potentially new Migrate methods:

  • \Drupal\migrate\Row::unsetEmptyDestinationProperty($property)

And potentially:

  • \Drupal\migrate\Plugin\MigrateProcessInterface::emptyDestination()
  • \Drupal\migrate\ProcessPluginBase::emptyDestination()

To determine when $row->setEmptyDestinationProperty($destination); is called by the MigrateExecutable.

Data model changes

N/A

Release notes snippet

✨ Feature request
Status

Active

Version

9.5

Component
MigrationΒ  β†’

Last updated about 13 hours ago

Created by

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024