InvalidArgumentException occurs when migrating d6 users. This migration is successful using Drupal 8.2.8.

The problem may be related to upgrade_d6_user_role. 8.2.8 successfully processes all 8 roles; 8.3.5 ignores three roles (1, 2 and 3) and leaves destid1 NULL in the migration map table. There are no messages in the migration message table. The migration fails on the second user.

Processed 8 items (5 created, 0 updated, 0 failed, 3 ignored) - done [status]
with 'upgrade_d6_user_role'
exception 'InvalidArgumentException' with message 'Passed variable is[error]
not an array or object, using empty array instead' in
/Users/tce/Sites/drupal-8.3.5/core/modules/migrate/src/Plugin/migrate/process/Flatten.php:51
Stack trace:
#0
/Users/tce/Sites/drupal-8.3.5/core/modules/migrate/src/Plugin/migrate/process/Flatten.php(51):
ArrayIterator->__construct('')
#1
/Users/tce/Sites/drupal-8.3.5/core/modules/migrate/src/MigrateExecutable.php(380):
Drupal\migrate\Plugin\migrate\process\Flatten->transform('',
Object(Drupal\migrate_tools\MigrateExecutable),
Object(Drupal\migrate\Row), 'permissions')
#2
/Users/tce/Sites/drupal-8.3.5/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php(223):
Drupal\migrate\MigrateExecutable->processRow(Object(Drupal\migrate\Row),
Array)
#3
/Users/tce/Sites/drupal-8.3.5/core/modules/migrate/src/MigrateExecutable.php(366):
Drupal\migrate\Plugin\migrate\process\MigrationLookup->transform('8',
Object(Drupal\migrate_tools\MigrateExecutable),
Object(Drupal\migrate\Row), 'roles')
#4
/Users/tce/Sites/drupal-8.3.5/core/modules/migrate/src/MigrateExecutable.php(203):
Drupal\migrate\MigrateExecutable->processRow(Object(Drupal\migrate\Row))
#5 [internal function]: Drupal\migrate\MigrateExecutable->import()
#6
/Users/tce/Developer/packages/drush-8.1.12/includes/drush.inc(720):
call_user_func_array(Array, Array)
#7
/Users/tce/Developer/packages/drush-8.1.12/includes/drush.inc(711):
drush_call_user_func_array(Array, Array)
#8
/Users/tce/Sites/drupal-8.3.5/sites/all/modules/migrate_tools/migrate_tools.drush.inc(282):
drush_op(Array)
#9 [internal function]:
_drush_migrate_tools_execute_migration(Object(Drupal\migrate\Plugin\Migration),
'upgrade_d6_user', Array)
#10
/Users/tce/Sites/drupal-8.3.5/sites/all/modules/migrate_tools/migrate_tools.drush.inc(248):
array_walk(Array, '_drush_migrate_...', Array)
#11 [internal function]: drush_migrate_tools_migrate_import()
#12
/Users/tce/Developer/packages/drush-8.1.12/includes/command.inc(422):
call_user_func_array('drush_migrate_t...', Array)
#13
/Users/tce/Developer/packages/drush-8.1.12/includes/command.inc(231):
_drush_invoke_hooks(Array, Array)
#14 [internal function]: drush_command()
#15
/Users/tce/Developer/packages/drush-8.1.12/includes/command.inc(199):
call_user_func_array('drush_command', Array)
#16
/Users/tce/Developer/packages/drush-8.1.12/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#17
/Users/tce/Developer/packages/drush-8.1.12/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#18 /Users/tce/Developer/packages/drush-8.1.12/drush.php(12):
drush_main()
#19 {main}

I can look into this some more if given suggestions where to look.

Comments

Tom Elwertowski created an issue. See original summary.

steve hanson’s picture

Same here - I am seeing one role import. and all the others are ignored. Then after that there is of course a whole lot of user import breakage.

mikeryan’s picture

Tom Elwertowski’s picture

Status: Closed (duplicate) » Active

This may be similar but is not a duplicate. This bug was filed against Drupal 8.3.5 (which includes #2850312: d6_filter_format is hard coded, causing dependent migration to fail).

steve hanson’s picture

Yes, my test was against 8.3.5 as well. In 8.3.4 it also failed, but differently.

quietone’s picture

Issue tags: +migrate-d6-d8

Add tag.

Tom Elwertowski’s picture

Looking at this some more, I found the cause of the failure. There is a MySQL table name skew.

The upgrade_d6_filter_format migration creates a table named migrate_map_upgrade_d6_filter_format. The upgrade_d6_user_role migration looks for (and creates) a table named migrate_map_d6_filter_format (no upgrade in name). The table is empty so some roles are ignored.

Similarly, the upgrade_d6_user_role migration creates a table with upgrade in the name and the upgrade_d6_user migration looks for (and creates) a table named migrate_map_d6_user_role (no upgrade in name). This one is empty too and results in the exception I reported.

A quick fix to make the user import work is to specify migration: upgrade_d6_filter_format for the filter_format_permission process plugin in upgrade_d6_user_role.yml and add the upgrade_ prefix to the two migration: d6_ specifications in upgrade_d6_user.yml.

I suspect the real fix is to make adding (or not adding) the upgrade_ prefix consistent somewhere in the migration code.

olarin’s picture

Priority: Normal » Major

I'm having the same issue with 8.3.5. Seems reasonable to me to consider this "Major" priority? It blocks the d6 migration process for many use cases.

olarin’s picture

Status: Active » Needs review
StatusFileSize
new813 bytes

After further reading of the code and issue #2850312 that mikeryan suggested this duplicates, I think I understand a little better, and it may well be a duplicate - but if so then I think 2850312 should not have been closed. If I'm not totally off base (which I may very well be), I think the default value for the migration ID that's being set in create method in FilterFormatPermission.php should be updated to include the "upgrade_" prefix. I don't know if this is actually the correct approach to the issue, but it does result in user roles importing correctly at least, so I'm posting it as a patch in the hopes of encouraging someone more knowledgeable about the migration system than I to take a look.

Status: Needs review » Needs work
olarin’s picture

Ah - after a few more days' digging, now I understand why my patch is silly and should feel bad. d6_filter_format is indeed the correct default for the migration ID. The "upgrade_" prefix comes from using the contrib migrate-upgrade and migrate-tools modules to run the upgrades from Drush (which, to be fair, is kind of the only good way to run migrations, at least when you want to step through piece by piece and see what is and isn't working and why). It still seems reasonable to me to expect all of this to work correctly out of the box, but I think the correct solution is a subtler combination of a patch to core to explicitly specify the default migration id for the FilterFormatPermission process plugin, and a patch to migrate_upgrade to make sure it correctly prefixes such migration ids (it tries to iterate through process plugins but right now I don't think it catches everything).

olarin’s picture

Status: Needs work » Needs review
StatusFileSize
new582 bytes

Here's a patch which adds the default migration ID for d6_filter_format as an explicit parameter for filter_format_permission in the d6_user_role migration template. By itself I believe it should have no effect, but it should allow the patch I just submitted to Migrate Upgrade in https://www.drupal.org/node/2898028 to properly prefix the ID when running the user role migration via drush migrate-upgrade and migrate-import.

Meanwhile, I think you should find that the similar issues for d6_user have already been solved in the latest dev version of Migrate Upgrade, by the commit for https://www.drupal.org/node/2875405.

Status: Needs review » Needs work
olarin’s picture

Status: Needs work » Needs review