I have been scratching my head over this issue. The source sometimes has a blank offers, sometimes it is an array with data and sometimes it is an empty array - like this one:
https://api.hel.fi/linkedevents/v1/event/matko:16134/
With the latter example I was getting a bunch of Array index missing, extraction failed exceptions from the extract plugin, despite the skip_on_empty
plugin running before, as you can see from my yml file:
field_offers_is_free:
-
plugin: skip_on_empty
method: process
source: offers
-
plugin: extract
index:
- 0
- is_free
field_offers_info_url:
-
plugin: skip_on_empty
method: process
source: offers
-
plugin: extract
default: false
index:
- 0
- info_url
- fi
I managed - in the end - to track down the reason for why our skip_on_empty plugin was never called: When Get sets $multiple
to true, processRow in MigrateExecutable runs a foreach on the value - causing the whole skip_on_empty plugin to be skipped.
With this quick fix in modules/migrate/src/Plugin/migrate/process/Get.php
's transform function things work fine for me:
if (is_string($source)) {
$a = is_array($return[0]);
$b = !empty($return[0]);
$this->multiple = $a && $b;
return $return[0];
}
Did I encounter a bug in Migrate or should I change my migration configuration?