I had a migration group consisting out of 4 (interdependent) migrations, all using the same Excel sheet as source data (although some of them used different sheets within the same file). When I ran the migrations through the CLI using drush, they worked as expected. When I ran the same migrations using MigrateBatchExecutable, some of the migrations failed with "NULL" values. Debugging showed that values were read from an incorrect worksheet (not the one defined in the migrate config).

I am not entirely sure, but I think this is caused by the fact that the SpreadsheetIterator is exposed as a service (migrate_spreadsheet.iterator), and can be re-used between migrations in the same request without being properly reset. In any case, it seems strange to implement an iterator as a service?

When I instantiate the SpreadsheetIterator in the Spreadsheet migrate plugin constructor, my migrations work flawlessly in both CLI and through MBE.

Patch attached for testing/review

CommentFileSizeAuthor
migrate_spreadsheet-iterator.patch1.22 KBmr.baileys
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mr.baileys created an issue. See original summary.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

@mr.baileys, you're absolutely right.

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Fixed

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.