From 18eae73c82da51f1bcdeb451adb2e1ccc0dd67c5 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Wed, 11 Sep 2019 10:49:37 +0100
Subject: [PATCH] =?UTF-8?q?Issue=20#3080492=20by=20quietone,=20G=C3=A1bor?=
 =?UTF-8?q?=20Hojtsy:=20Migrate=20fixed=20vocabulary=20term=20reference=20?=
 =?UTF-8?q?fields=20as=20translatable=20to=20conform=20to=20data=20expecta?=
 =?UTF-8?q?tions=20when=20nodes=20get=20merged?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Plugin/migrate/source/d7/FieldInstance.php   | 16 ++++++++--------
 .../Migrate/d7/MigrateFieldInstanceTest.php      |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php
index a69b71f42d58..74340884d29f 100644
--- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php
+++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php
@@ -152,11 +152,11 @@ public function prepareRow(Row $row) {
       $row->setSourceProperty('allowed_vid', $allowed_vid);
 
       // If there is an i18n_mode use it to determine if this field is
-      // translatable. It is TRUE only for i18n_mode 'Translate', all others are
-      // FALSE. When there is a term reference field with two vocabularies where
-      // one vocabulary is translatable and other is not the field itself is set
-      // to not translatable. Note mode '5' is not used for taxonomy but is
-      // listed here for completeness.
+      // translatable. It is TRUE for i18n_modes 'Vocab Fixed' and  'Translate',
+      // for all others it is FALSE. When there is a term reference field with
+      // two vocabularies where one vocabulary is translatable and other is not
+      // the field itself is set to not translatable. Note mode '5' is not used
+      // for taxonomy but is listed here for completeness.
       // - 0: No multilingual options.
       // - 1: Localize. Localizable object.
       // - 2: Fixed Language.
@@ -170,10 +170,10 @@ public function prepareRow(Row $row) {
           ->fields('v', ['i18n_mode'])
           ->condition('machine_name', $vocabulary, 'IN');
         $results = $query->execute()->fetchAllAssoc('i18n_mode');
-        $translatable = TRUE;
+        $translatable = FALSE;
         foreach ($results as $result) {
-          if ($result['i18n_mode'] != '4') {
-            $translatable = FALSE;
+          if ($result['i18n_mode'] == '2' || $result['i18n_mode'] == '4') {
+            $translatable = TRUE;
           }
         }
         $row->setSourceProperty('translatable', $translatable);
diff --git a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php
index fb6e9b399769..561e16246023 100644
--- a/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php
+++ b/core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php
@@ -164,7 +164,7 @@ public function testFieldInstances() {
     $this->assertFalse($field->isTranslatable());
 
     // Test the translation settings for taxonomy fields.
-    $this->assertEntity('node.article.field_vocab_fixed', 'vocab_fixed', 'entity_reference', FALSE, FALSE);
+    $this->assertEntity('node.article.field_vocab_fixed', 'vocab_fixed', 'entity_reference', FALSE, TRUE);
     $this->assertEntity('node.article.field_vocab_localize', 'vocab_localize', 'entity_reference', FALSE, FALSE);
     $this->assertEntity('node.article.field_vocab_translate', 'vocab_translate', 'entity_reference', FALSE, TRUE);
   }
-- 
GitLab