skip_on_empty documentation is confusing when skipping a process

Created on 24 January 2023, almost 2 years ago
Updated 12 July 2024, 4 months ago

Problem/Motivation

The skip_on_empty plugin documentation doesn't make clear that skipping a process sets the value to NULL, and is unclear as to what happens when running update migrations.

Proposed resolution

Adjust documentation to make it clear that skipping a process sets the process value to NULL, which will result in clearing the value in typical entity destinations.

Remaining tasks

Postponed on ✨ Allow process plugins to stop further processing on a pipeline RTBC .
Update docs to reflect changes made in that issue

User interface changes

TBD.

API changes

TBD.

Data model changes

TBD.

Original Issue Summary

The skip_on_empty plugin's documentation states:

 * The skip_on_empty process plugin checks to see if the current input value
 * is empty (empty string, NULL, FALSE, 0, '0', or an empty array). If so, the
 * further processing of the property or the entire row (depending on the chosen
 * method) is skipped and will not be migrated.

and a bit above

 * Available configuration keys:
 * - method: (optional) What to do if the input value is empty. Possible values:
(...)
 *   - process: Prevents further processing of the input property when the value
 *     is empty.

By the description, one would expect that, if the plugin is used with "method: process", and the target entity already has some value(s) on this field, then a possible empty value in the source would not be migrated; thus the field would preserve its pre-migration values.

This can also be seen in the plugin's source code that throws a MigrateSkipProcessException.

However, if one looks the MigrateExecutable's source code here and here, the MigrateSkipProcessException is caught, NULL value(s) is(are) assigned, and a bit below:

    // Ensure all values, including nulls, are migrated.
    if ($plugins) {
      if (isset($value)) {
        $row->setDestinationProperty($destination, $value);
      }
      else {
        $row->setEmptyDestinationProperty($destination);
      }
    }

So the field gets an empty value.

Steps to reproduce

  • Create a migration, with one of the fields using the skip_on_empty plugin.
  • Migrate some source that has values on this field.
  • Delete the value from the source.
  • Run the migration again.
  • See that, after the second migration, the value of the field is now empty.

I honestly don't know if this is the intended behaviour, or it is a bug.

Release notes snippet

TBD.

πŸ“Œ Task
Status

Fixed

Version

10.3 ✨

Component
MigrationΒ  β†’

Last updated about 16 hours ago

Created by

πŸ‡³πŸ‡΄Norway efpapado

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