diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermLocalizedTranslation.php b/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermLocalizedTranslation.php index b99761a89eab..ce44978b7618 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermLocalizedTranslation.php +++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermLocalizedTranslation.php @@ -37,6 +37,7 @@ class TermLocalizedTranslation extends Term { // Add in the property, which is either name or description. // Cast td.tid as char for PostgreSQL compatibility. $query->leftJoin('i18n_strings', 'i18n', 'CAST([td].[tid] AS CHAR(255)) = [i18n].[objectid]'); + $query->condition('i18n.type', 'term'); $query->addField('i18n', 'lid'); $query->addField('i18n', 'property'); @@ -69,6 +70,7 @@ class TermLocalizedTranslation extends Term { $other_property = ($property == 'name') ? 'description' : 'name'; $query = $this->select('i18n_strings', 'i18n') ->fields('i18n', ['lid']) + ->condition('i18n.type', 'term') ->condition('i18n.property', $other_property) ->condition('i18n.objectid', $tid); $query->leftJoin('locales_target', 'lt', '[i18n].[lid] = [lt].[lid]'); diff --git a/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermLocalizedTranslationTest.php b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermLocalizedTranslationTest.php index f6906dca978c..2eda7078a6d2 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermLocalizedTranslationTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/TermLocalizedTranslationTest.php @@ -181,6 +181,70 @@ class TermLocalizedTranslationTest extends MigrateSqlSourceTestBase { // Empty configuration will return terms for all vocabularies. $tests[0]['configuration'] = []; + // Test that only i18n_strings of type 'term' are returned. + $tests[1] = $tests[0]; + $tests[0]['source_data']['i18n_strings'] = [ + [ + 'lid' => 6, + 'objectid' => 1, + 'type' => 'term', + 'property' => 'name', + 'objectindex' => '1', + 'format' => 0, + ], + [ + 'lid' => 7, + 'objectid' => 1, + 'type' => 'term', + 'property' => 'description', + 'objectindex' => '1', + 'format' => 0, + ], + [ + 'lid' => 8, + 'objectid' => 3, + 'type' => 'not term', + 'property' => 'name', + 'objectindex' => '3', + 'format' => 0, + ], + [ + 'lid' => 9, + 'objectid' => 4, + 'type' => 'term', + 'property' => 'description', + 'objectindex' => '4', + 'format' => 0, + ], + ]; + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'tid' => 1, + 'vid' => 5, + 'name' => 'name value 1', + 'description' => 'description value 1', + 'weight' => 0, + 'parent' => [0], + 'property' => 'name', + 'language' => 'fr', + 'name_translated' => 'fr - name value 1 translation', + 'description_translated' => 'fr - description value 1 translation', + ], + [ + 'tid' => 1, + 'vid' => 5, + 'name' => 'name value 1', + 'description' => 'description value 1', + 'weight' => 0, + 'parent' => [0], + 'property' => 'description', + 'language' => 'fr', + 'name_translated' => 'fr - name value 1 translation', + 'description_translated' => 'fr - description value 1 translation', + ], + ]; + return $tests; }