Allow MigrateStub class to throw MigrateSkipRowExceptions

Created on 16 May 2024, about 1 month ago
Updated 20 May 2024, 28 days ago

Problem/Motivation

If you use the `migration_lookup` plugin to stub another migration, any `plugin: skip_on_empty / method: row` processes in the secondary migration are silently ignored. The row is skipped, but there is no data on it being processed as you would see in a non-stub migration execution (where the destination ID is `NULL` and an entry is added to the migrate_message_x table for it with your custom message).

Steps to reproduce

1. Have a "parent" migration with a process like this:

```
process:
plugin: migration_lookup
migration: child_migration
source: my_id
```

2. Have a "child" migration like this:

```
process:
_skip_conditions:
plugin: skip_on_empty
method: row
message: 'do not stub or import me, but log for tracking purposes'
source: something_that_might_be_null
```

Proposed resolution

As suggested by Michael Lutz, we can modify the MigrateStub:doCreateStub method to process these exceptions:

Before:

```
...
$migrate_executable->processRow($row, $process);
...

After:

```
try {
$migrate_executable->processRow($row, $process);
}
catch (MigrateSkipRowException $e) {
// code here
}
```

Remaining tasks

Use patch if you need this in 10.x. Otherwise, it's advised to use decorators on the migrate.stub service in 11.x.

User interface changes

N/A

API changes

Yes.

Data model changes

N/A

Release notes snippet

N/A

✨ Feature request
Status

Closed: works as designed

Version

10.4 ✨

Component
MigrationΒ  β†’

Last updated about 10 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States amaisano Boston

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024