It took me a while, to figure out why the migrated files where added to files_managed but actually not attached to the file field. The problem was by default y set the subfield language to the entity language, but the file field by default is not translatable so it should be LANGUAGE_NONE instead.

Would be nice if migrate offers the language subfield only for translatable fields to not mislead developers.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

osopolar’s picture

Status: Active » Needs review
FileSize
1.51 KB

Patch attached.

Currently I don't have enough migrations to widely test the changes, but it is working for body field (translatable) and file field (not translatable).

osopolar’s picture

Title: Add langauge subfields only if field is translatable » Add language subfields only if field is translatable
mikeryan’s picture

Status: Needs review » Needs work
Issue tags: -Migrate 2.7 +Migrate 2.8
+++ b/plugins/destinations/fields.inc
@@ -342,8 +342,11 @@ class MigrateTextFieldHandler extends MigrateFieldHandler {
+    if ($field_info['translatable']) {

I'd suggest using field_is_translatable(), which also checks for a translation handler.

osopolar’s picture

Do you mean like this:

$field = field_info_field($instance['field_name']);
if (field_is_translatable($instance['entity_type'], $field)) {
osopolar’s picture

Status: Needs work » Needs review
mikeryan’s picture

That looks good to me. I don't have suitable data to test locally - is there someone else out there who can verify and set the status to rtbc?

Thanks.

  • mikeryan committed 4b2d4d4 on 7.x-2.x authored by osopolar
    Issue #2472045 by osopolar: Add language subfields only if field is...
mikeryan’s picture

Went ahead and committed this, thanks!

mikeryan’s picture

Status: Needs review » Fixed

  • mikeryan committed 13e294c on 7.x-2.x
    Issue #2472045 by mikeryan: Remove now-unnecessary language mappings...

Status: Fixed » Closed (fixed)

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