Problem/Motivation

In Drupal 6 Node translation concept each language version is a separate node with their own nid. Each of these nodes can have their own taxonomy term references.

In Drupal 6, you can use the I18n Taxonomy module to translate a taxonomy vocabulary and taxonomy terms. There are two different multilang concepts: 'localized' and 'per language'.

This issue is about the references from the migrated Node translations to the terms. Currently the translation of the node does not get the reference to the taxonomy term. Only the primary language version of the node has the reference to the term in Drupal 8.

Proposed resolution

Related issues out of scope of this issue:

The scope of this issue is the reference from the node translation to the taxonomy term.

Test case 1 when using 'Localized' vocabulary.

  • Have two node entities in Drupal 6, one in English (nid 1) and one for example in Finnish (nid 2). Associate these as translations of each other.
  • Have one taxonomy term in Drupal 6 which is translated in Drupal 6 at admin/build/translate. The vocabulary must have the 'Localized' multilingual setting.
  • Make sure that both English and Finnish versions of the Drupal 6 node have a reference to the term.
  • The translation of the term and the vocabulary language settings must have been previously migrated, see #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms and #2975509: Migrate D6 vocabulary language settings.

Expected result:

  • The Finnish language version of the node is migrated as a translation to the English node. In other words, there were 2 nodes in Drupal 6 but there will only be 1 node in Drupal 8.
  • When viewing the Finnish translation of the Drupal 8 node, it must have a reference to the term.

Implementation:
The localized vocabulary is 'field_vocabulary_name_much_longe' on the content type 'employee'.
Two nodes in the employee content type.
John Smith - EN
field_vocabulary_name_much_longe: 'term 4 of vocabulary 3': source tid 4
John Smith - FR
field_vocabulary_name_much_longe: 'fr - term 4 of vocabulary 3': source tid 9

Test case 2 when using 'Per language' vocabulary.

  • Have two node entities in Drupal 6, one in English and one for example in Finnish. Associate these as translations of each other.
  • Have two taxonomy terms in Drupal 6. The vocabulary must have the 'Per language' multilingual setting. Both taxonomy terms will have their language defined.
  • Make sure that the English node has a reference to the English term in Drupal 6.
  • Make sure that the Finnish node has a reference to the Finnish term in Drupal 6.

Expected result:

  • The Finnish language version of the node is migrated as a translation to the English node. In other words, there were 2 nodes in Drupal 6 but there will only be 1 node in Drupal 8.
  • When viewing the English version of the Drupal 8 node (original language of the node), it must have a reference to the English term.
  • When viewing the Finnish translation of the Drupal 8 node, it must have a reference to the Finnish term.

Implementation:
The per language vocabulary is 'field_vocabulary_3_i_2_' on the content type 'employee'.
Two nodes in the employee content type.
John Smith - EN
field_vocabulary_3_i_2_: Vulcan: source tid 15
John Smith - FR
field_vocabulary_3_i_2_: fr - Talos IV: lid 1692 : source tid 14

Remaining tasks

Patch
Test & Review
Commit

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Original issue report by @jhodgdon

I tested today migrating a D6 site that had:
- One content type with translations into Spanish (using Content Translation and i18n and CCK translation)
- One taxonomy vocabulary with translations into Spanish (using i18n taxonomy)
- This taxonomy vocabulary was on this content type

The English nodes and taxonomy terms came through OK.

The Spanish taxonomy term translations didn't migrate. This is #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms.

Also, the Spanish nodes did not have taxonomy terms assigned to them. That is what this issue is about: to fix that (but first it requires that the taxonomy translations are migrated).

Related investigation of the 'Per language' concept

#2979486: Migrate D6 'per language' multilingual vocabularies & terms

Comments

jhodgdon created an issue. See original summary.

jhodgdon’s picture

Note: maybe this issue will be fixed when taxonomy migrates correctly, but it probably at least needs a test added here.

gábor hojtsy’s picture

I think there are entity reference migration problems overall that may be more related to this, given taxonomy terms are a special case of entity reference now. I suspect the field is set translated but the translations entity references never get the taxonomy term value set.

gábor hojtsy’s picture

Hm, so as per @catch the main reference issue outstanding is #2447727: Add base class for migrating reference fields which is not Drupal 6 related on a cursory look. So may not get you a solution there...

jhodgdon’s picture

Now that taxonomy terms and vocabularies migration is in, probably this needs a retest to see if it is still a problem. I'll try to make time for that sometime soon.

jhodgdon’s picture

I retested today. What I did:

a) Install today's Drupal 8.4.x with Minimal install profile in English, using the install UI.
b) Install the Migrate, Migrate Drupal, and Migrate Drupal UI modules from admin/modules.
c) Went to /upgrade (migrate UI page). This advised me to install modules on this site that were used on the d6 site, so I installed Taxonomy, Comment, Custom Block, Path, Views, all the field types except Telephone, and the i18n modules.
d) Went back to /upgrade and did the migration from there, of the site described in the issue summary (with translated taxonomy terms being used on translated nodes). It took a while...
e) Went to the Text Formats page and resaved 2 text formats that have missing filters from a contrib module that isn't ported, so I could see the content and not get confused about whether it migrated or not.

So, the result, regarding taxonomy and this content type:

1. I don't see any translations of my taxonomy terms coming in. I'll comment on the related taxonomy term migration issue.
2. The taxonomy vocabulary is not translated as far as I can see either. I'll comment on the vocabulary issue.
3. The nodes came through in English with Spanish translations, but the Spanish translations have no tags.

So... I think this is still a problem.

jhodgdon’s picture

Issue summary: View changes
Status: Active » Postponed

Added #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms ... this needs to be postponed until that issue is fixed.

quietone’s picture

Issue tags: +migrate-d6-d8

Add tag.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

gábor hojtsy’s picture

masipila’s picture

We need to do the same thing for D7-D8. What do others think, should we open a separate issue for that or increase the scope of this issue to cover both?

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Issue tags: +i18n-migrate

Add tag.

masipila’s picture

Title: Migrate d6 translated nodes with translated taxonomy » Migrate node & taxonomy term relations when using D6 Node translation & D6 'Localized terms'
Issue summary: View changes

Updated issue summary as part of clarifying the scope for each of the multilingual vocabulary / term migration issues.

masipila’s picture

Status: Active » Postponed

Postponed on #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms. The other related issue is a soft blocker as the multilingual settings of the vocabulary can be easily modified manually in D8 #2975509: Migrate D6 vocabulary language settings.

masipila’s picture

Title: Migrate node & taxonomy term relations when using D6 Node translation & D6 'Localized terms' » Migrate taxonomy term references for D6 Node translations
Issue summary: View changes
Related issues: +#2979486: Migrate D6 'per language' multilingual vocabularies & terms

Further updates to the issue summary.

Postponed on #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms. The other related issue is a soft blocker as the multilingual settings of the vocabulary can be easily modified on Drupal 8 site, see #2975509: Migrate D6 vocabulary language settings.

masipila’s picture

Issue summary: View changes
masipila’s picture

Status: Postponed » Active

Unpostponed as this landed: #2886609: Migrate translations for D6 i18n taxonomy 'localized' terms. The D7 part might need a separate follow-up.

heddn’s picture

Issue tags: +Migrate critical

Triaging the issue queue.

quietone’s picture

Assigned: Unassigned » quietone
Status: Active » Needs review
StatusFileSize
new12.2 KB

For test case 1:
Add a localized taxonomy term to the employee content type and add data. Then add a test for the migration of localized term on a translated node. But the test fails in the migration with

1) Drupal\Tests\taxonomy\Kernel\Migrate\d6\MigrateTermNodeTranslationTest::testTermNode
A translation already exists for the specified language (fr). (/opt/sites/d8/core/lib/Drupal/Core/Entity/ContentEntityBase.php:810)
Failed asserting that false is true.

Next is to find out why it doesn't just update the entity.

Status: Needs review » Needs work

The last submitted patch, 22: 2859297-22.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review

Ah, I forgot to add 'translations: true' to the migration.

quietone’s picture

StatusFileSize
new13.28 KB
new13.28 KB

Remove some test code and comments left in the previous patch by mistake.

This adds 'translations: true' to the destination in d6_term_node_translation.yml allowing the translation to be saved. But the vid wasn't being updated and found that d6_term_node_translation needed to be added to the list of plugins altered in migrate_drupal_migration_plugins_alter in migrate_drupal. Then found that the vocabulary Id being saved for the translated node was the same as for the untranslated node. Changing the vocabulary field to be translatable fixed that. That was done in d6_vocabulary_field_instance.yml and I'm sure other tests will fail because of that. So, stopping now to see what testbot finds.

Status: Needs review » Needs work

The last submitted patch, 25: 2859297-25.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

StatusFileSize
new3.77 KB

The interdiff for the above patch

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new91.64 KB
new85.72 KB

Add source data and test for test case 2, 'per language'. Also, some cleanup and comments.

Status: Needs review » Needs work

The last submitted patch, 28: 2859297-28.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new91.64 KB

Status: Needs review » Needs work

The last submitted patch, 30: 2859297-30.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new10.55 KB
new84.86 KB

Trimming the changes to the fixture.

Status: Needs review » Needs work

The last submitted patch, 32: 2859297-32.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new10.55 KB
new706 bytes

Adjust the field entity count

Status: Needs review » Needs work

The last submitted patch, 34: 2859297-34.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new10.49 KB
new646 bytes

Fix for Upgrade6Test.

Status: Needs review » Needs work

The last submitted patch, 36: 2859297-36.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.13 KB
new10.95 KB

Change the migrate_drupal plugin_later to only add d6_term_node_translation if the module config_translation is installed.

Status: Needs review » Needs work

The last submitted patch, 38: 2859297-38.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new10.98 KB
new636 bytes

Need to enable config_translation too!

quietone’s picture

Status: Needs review » Needs work

Just want to double check that the source data matches the recommendation in the IS.

quietone’s picture

Issue summary: View changes
Status: Needs work » Needs review

Added the implementation of the Case scenarios to the IS. It looks like the cases are covered. Therefor this is ready for review.

quietone’s picture

Assigned: quietone » Unassigned
jhodgdon’s picture

Would it help for me to go back to my D6 actual site that triggered me filing this issue, and test it again with this patch?

quietone’s picture

@jhodgdon, yes! Much appreciated.

jhodgdon’s picture

I did a manual test of this patch today. See comment #6 for my test procedure (changes: I started with Standard install profile not Minimal, so I had fewer additional modules to install, and I used 8.7.x with the patch in #40 applied). See the "original report" section of the issue summary for a description of the D6 site that I was testing with.

So, results:

a) I got two errors that look like this during taxonomy migration:

Migration failed with source plugin exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'lt.i18n_status' in 'field list':

SELECT i18n.*, lt.translation AS translation, lt.language AS language, lt.plid AS plid, lt.plural AS plural, lt.i18n_status AS i18n_status, cnf.field_name AS field_name, cnf.global_settings AS global_settings, cnf.type AS type, i18n.type AS i18n_type, cnfi.type_name AS type_name FROM {i18n_strings} i18n LEFT OUTER JOIN {locales_target} lt ON lt.lid = i18n.lid LEFT OUTER JOIN {content_node_field} cnf ON cnf.field_name = i18n.objectid INNER JOIN {content_node_field_instance} cnfi ON cnf.field_name = cnfi.field_name WHERE (i18n.type = :db_condition_placeholder_0) AND (property LIKE :db_condition_placeholder_1 ESCAPE '\\') AND (translation IS NOT NULL); 

Array ( [:db_condition_placeholder_0] => field [:db_condition_placeholder_1] => option\_% )

Operation on Field instance option configuration translation failed

b) Woot!! My translated vocabulary came through with translated terms! I guess that was a different issue. Anyway, that's good. I'm not sure I'd tested since that was fixed.

c) Woot!! My bilingual blog posts came through with taxonomy on them, and when I view them, I see the appropriate translation. So, that's good too.

So... I don't know if (a) is related to this issue or not, but it doesn't seem to have caused a problem, at least for the spot check of content I looked at.

quietone’s picture

Awesome, 2 'Woot!!'s. It was nice to see that this morning.

Now the error message in 46.a is interesting. I can't find where it is created in my local Drupal 6. So, I went to http://cgit.drupalcode.org/i18n/tree/i18nstrings/i18nstrings.install?h=6... and found it is created in this:

/**
 * Implementation of hook_schema_alter().
 */
function i18nstrings_schema_alter(&$schema) {
  // Add index for textgroup and location to {locales_source}.
  $schema['locales_source']['indexes']['textgroup_location'] = array(array('textgroup', 30), 'location');
  // Add field for tracking whether translations need updating.
  $schema['locales_target']['fields']['i18n_status'] = array(
    'description' => 'A boolean indicating whether this translation needs to be updated.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  );
}

but my local has

/**
 * Implementation of hook_schema_alter().
 */
function i18nstrings_schema_alter(&$schema) {
  // Add index for textgroup and location to {locales_source}.
  $schema['locales_source']['indexes']['textgroup_location'] = array(array('textgroup', 30), 'location');
  // Add field for tracking whether translations need updating.
  $schema['locales_target']['fields']['status'] = array(
    'description' => 'A boolean indicating whether this translation needs to be updated.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  );
}

The difference is that one has a column of 'i18n_status' and the other is 'status'. The change is in the last commit before The Great Git Migration. So, do we handle both situations or not? I don't recall if there ever was a decision for migrate to handle the latest dev version or the latest release of a module and I don't think we have ever run into a similar situation. But, to answer my question, I think common sense rules and both table schemas should be handled. Someone correct me if I am wrong.

quietone’s picture

The error in #46.a is not caused by this patch so it is moved to a new issue #3035259: Unknown column 'lt.i18n_status' in 'field list'.

masipila’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed patch #40 and repeated the manual test. So we have now two independent manual tests, first by @jhodgdon and now from me.

Test results from my manual tests:

D6 test setup

  • I have two language in D6: English and Finnish
  • Story content type has two different taxonomy terms. One uses 'localized' and the second 'per language' setting.

Test 1 against the acceptance criteria of the issue summary:

  • I created one pair of translated nodes which are associated with each other as translations.
  • Both language versions of this node have a 'localized' term associated with it. The 'localized' term is translated in D6 using string translation.

Test 2 against the acceptance criteria of the issue summary:

  • I created two terms to the 'per language' taxonomy. One in English and one in Finnish.
  • I created a second pair of translated nodes which are associated with each other as translations.
  • The English node has the English 'per language' term and the Finnish node has the Finnish 'per language' term.

Test results
Test 1:

  • The node pair is migrated to D8 so that we have one shared nid for both node language versions.
  • The 'localized' term is migrated to D8 so that we have shared tid for both term language versions.
  • The English version of the node is associated with the term. TEST OK.
  • The Finnish version of the node is associated with the term. TEST OK.
  • TEST 1 PASSED.

Test 2:

  • The node pair is migrated to D8 so that we have one shared nid for both node language versions.
  • There are two different terms migrated in the 'per language' taxonomy. One of them is in English and another in Finnish. These terms have different tids.
  • The English version of the node is associated with the English term. TEST OK.
  • The Finnish version of the node is associated with the Finnish term. TEST OK.
  • TEST 2 PASSED.

Patch review results
I reviewed the patch. It looks good to me. The D6 fixture has test data for both tests described above and there is test coverage for both tests.

Conclusion:

  • I did not encounter the issue reported in #46.a. @quietone already explained the background for that + created a follow-up
  • The patch #40 has been reviewed by me and it looks good.
  • The patch #40 has been manually tested by both @jhodgon and by me and both were reporting positive test results.
  • RTBC. Let's land this. Thank you so much @quietone for your excellent work with this. These multilingual taxonomy migrations are ridiculously complex but you mastered this perfectly. Woop, woop!

Cheers,
Markus

masipila’s picture

Queued the latest patch also for PostgreSQL and SQLite to be on the safe side.

masipila’s picture

Issue summary: View changes

Removed the TODO item from the issue summary on the D7 evaluation. I opened #3035392: Migrate vocabulary translations and taxonomy term references for Drupal 7 node translations as a D7 follow-up for this.

quietone’s picture

Retesting PostgreSQL, some CI error happened.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/content_translation/migrations/d6_term_node_translation.yml
@@ -0,0 +1,44 @@
+migration_tags:
+  - Drupal 6
+  - Content

This should be tagged multilingual, no?

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new10.99 KB
new568 bytes

Yes, it should! Thanks. All fixed but it looks like there is a PostgreSQL error.

Status: Needs review » Needs work

The last submitted patch, 54: 2859297-54.patch, failed testing. View results

quietone’s picture

The MySQL errors are unrelated, Media.Drupal\Tests\media\FunctionalJavascript\MediaStandardProfileTest
Sadly the PostgreSQL one is

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Resting

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.79 KB
new14.17 KB

The problem here is that the source plugin id is not including the language and that the query can return rows with a NULL language. That has been fixed and the test updated to test for both the zu and fr translation of a vocabulary which should prevent this in the future.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

All feedback seems addressed.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new14.17 KB

Rerolling, which is just a change to the field_config entity count in Upgrade6Test.

masipila’s picture

Queued for PostgreSQL and & SQLite once more

quietone’s picture

Ah, good thinking masipila.

masipila’s picture

Can we have an interdiff between 59-62?

Edit: 59-62, not 60-62

quietone’s picture

Because of the reroll, the interdiff fails. However, fortunately it was only a one line change and I remember what it was, it was this line.

+++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/Upgrade6Test.php
@@ -68,7 +68,7 @@ protected function getEntityCounts() {
+      'field_config' => 95,
masipila’s picture

Status: Needs review » Reviewed & tested by the community

Ok, thanks, fair enough.

I tested this thoroughly (manually) earlier, see #49. Since then, @quietone had to make some changes in #59 to resolve a test failure. @heddn reviewed this in #60.

The test cases for both localized and per language vocavularied are defined in the IS and they as well as their implementation.

Since the automated tests are green on all three databases and all feedback has been addressed, this is ready to land.

Thanks Vicki!

Markus

  • Gábor Hojtsy committed 955ffc8 on 8.8.x
    Issue #2859297 by quietone, masipila, jhodgdon, Gábor Hojtsy, heddn:...
gábor hojtsy’s picture

Version: 8.8.x-dev » 8.7.x-dev

Thanks a lot! Committed to 8.8. This cannot be merged to 8.7 at this point due to commit freeze though. Keeping RTBC for 8.7.x.

  • Gábor Hojtsy committed fbba2a3 on 8.7.x
    Issue #2859297 by quietone, masipila, jhodgdon, Gábor Hojtsy, heddn:...
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs reroll

Finally was able to merge in, sorry for the delay.

Status: Fixed » Closed (fixed)

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