Skip to content

sync might be too strict during id comparison; rolls back everything

Issue #3104268 on drupal.org by ahebrank.

I was noticing with a migrate_plus Url migration that the sync option was rolling back everything each import when the source had not changed. It's because the in_array id check (https://git.drupalcode.org/project/migrate_tools/blob/8.x-4.x/src/EventS...) is pretty fragile. In my case, $row->getSourceIdValues() was returning:

[ 'item_id' => INT ]

while $id_map->currentSource() was returning

[ 'item_id' => STRING ]

which causes a false negative for the strict in_array check.

I don't think this is the fault of migrate_tools, but I think it can be prevented. Incoming patch hashes IDs to JSON before comparison, which fixes my use case but might be inefficient.