Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 299138

file_field migration does not play nice with custom file migrations

$
0
0

Hi,

I am setting up a custom migration from Drupal 6 with the prefix “ao2_it_” and when migrating nodes I noticed that the attached file fields are not imported correctly, instead stub files are being created and used in the destination field.

I have a custom migration for files in migrate_plus.migration.ao2_it_d6_file.yml where I set source_base_path to the path of my images in the D6 site, and when executing drush migrate-import ao2_it_d6_file the files themselves get imported correctly under sites/default/files/ in the D8 site and the file_managed table in the D8 database looks OK too.

However when importing the nodes with drush migrate-import ao2_it_d6_node_blog something goes wrong when importing the file fields.

This is a snippet of the custom nodes migration:

id: ao2_it_d6_node_blog
class: Drupal\migrate\Plugin\Migration
...
process:
  ...
  field_file:
    plugin: d6_field_file
    source: field_file
  field_image:
    plugin: d6_field_file
    source: field_image
...

Looking at the d6_field_file migration in core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php I noticed that another process plugin is used to look at the migrated files but its id is hardcoded to d6_file, while I used a custom plugin for files named ao2_it_d6_file and this seems to be the cause of the issue I am seeing (stub files being created by d6_file).

In fact I see that, as expected, the ao2_it_d6_file migration created the migrate_map_ao2_it_d6_file table with the correct migration mapping, but then the d6_file_field process plugin does not seem to use it to find the migrated fid, instead after the node migration I see that a migrate_map_d6_file table has been created with the mapping to the stub files.

For the time being, as a local workaround, I am using this patch:

--- core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php.orig	2017-11-23 12:31:43.472719529 +0100
+++ core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php	2017-11-23 12:31:31.268983062 +0100
@@ -51,7 +51,7 @@ class FieldFile extends ProcessPluginBas
     // Configure the migration process plugin to look up migrated IDs from
     // a d6 file migration.
     $migration_plugin_configuration = $configuration + [
-      'migration' => 'd6_file',
+      'migration' => 'ao2_it_d6_file',
       'source' => ['fid'],
     ];
 

With this I can complete the node migration successfully.

Can you suggest a more general solution?
Can this be considered a bug or am I overlooking something?

Thanks,
Antonio


Viewing all articles
Browse latest Browse all 299138

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>