Problem/Motivation
The result of migration_lookup would appear to be one of two things:
- successful lookup
- failed lookup
but that is not actually the case. It can be one of THREE things:
- A. successful lookup for a migrated item
- B. successful lookup for an item which the migration ignored
- C. failed lookup
In my use cases, B and C should be treated the same: there is no migrated record found in the migration. For example, in a migration of translations, I look up the original language migration:
mid:
-
plugin: migration_lookup
migration: mixed_video_as_link_url
no_stub: true
source:
- id
- revision_id
- content_translation_source/0/value
-
# Skip the row if the lookup returns nothing because the original
# migration skipped.
plugin: skip_on_empty
method: row
However, the migration_lookup process plugin returns different things for cases B and C:
- A: an array of destination IDs
- B: an array of NULLs, because the lookup migration map has NULLs in it
- C: an empty array
The problem is that skip_on_empty can't catch both cases B and C.
Currently, because of #2905929: skip_on_empty doesn't work if the value is an empty array, it can't catch case C. If we fix that bug, then it won't catch case B, because an array of NULLs will get considered as a single value, and an array of NULLs is not empty.
Steps to reproduce
Proposed resolution
I don't see how the skip_on_empty plugin can handle both of these cases, even if we address its various issues (#3254356: [meta] skip_on_empty problems with arrays).
That plugin's concept of 'empty' should match PHP's, otherwise we're creating a WTF. So an array of NULLs should not be skipped if we fix #2905929: skip_on_empty doesn't work if the value is an empty array.
Either:
A. Build the skipping option into the migration_lookup process plugin
B. Add a new process plugin called 'skip_on_empty_lookup'
C. Add an option to the migration_lookup process plugin for it to return an empty array for all-NULL destination IDs
I'm leaning towards option C.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet