Field values for new media entity references on node bundles are not getting populated

Here is the migration config I'm using:

  field_image_media:    
    -    
      plugin: sub_process    
      source: field_thumbnail    
      process:    
        target_id:    
          -    
            plugin: migration_lookup    
            source: fid    
            migration: upgrade_d7_file    
            no_stub: true    
          -    
            plugin: update_file_to_image    

When using the update_file_to_document plugin, this config works for creating new media entities and populating the node entity reference fields with the correct values. For image media, the field_image_media_target_id (for a field_image_media field) is always 1, which is obviously not correct.

I've gone over this a little in the #migration slack channel, and was happy to get the migration working for document (file) fields, but I haven't been able to get the image fields to migrate in the same way, which is why I'm opening an issue here, for some more visibility while I continue to debug my process.

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:

Comments

stephenplatz created an issue. See original summary.

srjosh’s picture

Category: Bug report » Support request

are you sure that it's fid, and not target_id?

stephenplatz’s picture

Changing source: fid to source: target_id does not populate the field at all. With fid the field does get populated if I look in that table, but the values for the target id are wrong.

stephenplatz’s picture

It turns out this is because the transform method in the UpdateFileToImage plugin class is returning the entire $media object, and not just the $media->id(), which is what's needed for the target_id destination property. This was actually fixed in a previous commit, but it's not reflected in the latest release for some reason. I guess steps need to be taken to make sure that the latest packaged release has the most recent versioned code in it.

stephenplatz’s picture

Category: Support request » Task
Priority: Normal » Major
srjosh’s picture

Status: Active » Postponed

I'm going to be releasing the 2.1 version shortly; it will contain this fix and many others.

srjosh’s picture

Status: Postponed » Closed (outdated)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.