Problem/Motivation

In line 76 of the "FieldFile" class in "web/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php" the $lookup_result will always result in an empty array, if the migrations are defined using migrate upgrade + migrate tools with the "--configure-only" flag.

This is because $this->migrateLookup->lookup() does NOT use "An array of migration plugin IDs to look up, or a single ID as a string"(source: method documentation) as the parameter but instead the migration ID, which should be correctly "upgrade_d6_file" instead of "d6_file" (current value) when previously generated using drush migrate-upgrade --legacy-db-key=migrate --configure-only.

This leads to all file fields not having any files attached, when migrated.

Steps to reproduce

  • Generate migrations via drush migrate-upgrade --legacy-db-key=migrate --configure-only.
  • Make sure your source db has entity bundles using file fields
  • Run drush migrate-import --group=my_migration_group --continue-on-failure

Proposed resolution

Dynamically use the correct ID of the generated migration file.

Workaround:
See MR:
Change this line:

$lookup_result = $this->migrateLookup->lookup('d6_file', [$value['fid']]);

to

$lookup_result = $this->migrateLookup->lookup('upgrade_d6_file', [$value['fid']]);

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3322542

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grevil created an issue. See original summary.

Anybody made their first commit to this issue’s fork.

Anybody’s picture

Thanks, @Grevil, I can confirm this issue, still wondering how that can happen.

Might this be related to #2826204: migration using d6_cck_file/d6_field_file process plugin does not work with migration-prefix drush option?

I added an example, how it was fixed in our case, but I guess this static change is wrong and needs to be done dynamically? But I have no clue how to do that correctly, please need help from someone from the core migration team.

Anybody’s picture

Title: "d6_field_file" migration plugin static lookup, leads creating empty file fields » Drupal 6 "d6_field_file" migration plugin static lookup, leads creating empty file fields
Issue summary: View changes
Anybody’s picture

Issue summary: View changes
quietone’s picture

Status: Active » Closed (duplicate)
Issue tags: +Bug Smash Initiative
Related issues: +#3091841: Remove hardcoded plugin IDs from migration process plugins

Yes, this is a known problem and there is an existing issue. The suggested fix would break core migrations and any others that use migrate-upgrade. I am closing this as a duplicate.

Fixes welcome over in the original issue and if you want a review, ping me in #migration.

Thanks!

Anybody’s picture

Thanks, @quietone, sorry I didn't see this relation. That issue is really horrible, I'm sure it cost us days already. Let's proceed there.

Grevil’s picture

Attached the static patch, if anyone still needs it until #3091841: Remove hardcoded plugin IDs from migration process plugins is fixed.