Problem/Motivation

This D7 migration has been move out of #2981393: Migrate D6 comment type language settings because the D7 fixture is broken and needs to be fixed before work continues.

In #2981392: Comment migration corrupts data with multilingual sites we found out that the comment type language settings are not migrated sensibly when the source content type has multilingual support enabled.

Migrations generate one comment type for each Drupal 7 content type (except Forum which uses the hard coded comment_forum). The D8 comment type has a default language for new comments, see the screenshot below.
D8 comment type language settings

Currently we leave the default language (for new comments created in D8) to site default language. We also do not show the language selector for comments so that users could change the comment language when they are creating / editing the comments.

Proposed resolution

1. If the Drupal 7 content type has multilingual support 'disabled'.
Drupal 7 fixture: book.

  • 'Default language' setting of the comment type: 'Site default'.
  • 'Show language selector' setting of the comment type: disabled.
  • 'Enable translation' setting of the comment type: disabled.

2. If the Drupal 7 content type has multilingual support 'enabled'.
Drupal 7 fixture: Page.

This means that the nodes can have a language code but the different nodes cannot be linked as translations of each other.

  • 'Default language': 'Interface text language selected for page' instead of 'Site default'.
  • 'Show language selector': enabled. This way the D8 user can see what the language of the new comments will be.
  • 'Enable translation': disabled. This is because the comments in D7 are independent i.e. the comments are not translations of each other.

3. If the Drupal 7 content type has multilingual support 'Enabled, with translation'.
Drupal 7 fixture: article and blog.

This means that the nodes can have a language code and the nodes with different language codes can be linked as translations of each other. The different node language versions will have their independent comments i.e. the comments are not translations of each other.

  • 'Default language': 'Interface text language selected for page' instead of 'Site default'.
  • 'Show language selector': enabled. This way the D8 user can see what the language of the new comments will be.
  • 'Enable translation': disabled. This is because the comments in D7 are independent i.e. the comments are not translations of each other.

4. If the Drupal 7 content type has multilingual support as 'Enabled, with field translation'.
Drupal 7 fixture: test_content_type.

  • 'Default language': 'Interface text language selected for page' instead of 'Site default'.
  • 'Show language selector': enabled. This way the D8 user can see what the language of the new comments will be.
  • 'Enable translation': Depends on the Entity Translation settings in Drupal 7 (admin/config/regional/entity_translation).
    • If the 'Translatable Entity Types' include Comments, then it means that actual comments entities can be translated and D8 'Enable translation' should be enabled.
    • If the 'Translatable Entity Types' does NOT include Comments, then it means that actual comments entities can NOT be translated and D8 'Enable translation' should be disabled.
    • Reference: The Entity Translation settings were originally handled in #2073467: Migrate Drupal 7 Entity Translation settings to Drupal 8. I'm not sure if this variation was included in that issue.

Remaining tasks

1. Patch
2. Review and test
3. Commit

User interface changes

Enables the comment language selector + changes the default comment language for multilingual sites.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quietone created an issue. See original summary.

quietone’s picture

This is D7 part of the patch from 2981393.#59

Removed references to D6 in the IS, that should be sufficient

Status: Needs review » Needs work

The last submitted patch, 2: 3024460-2.patch, failed testing. View results

quietone’s picture

masipila’s picture

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

I tested path #4 manually.

1. Content type with multilingual settings 'disabled': All three language settings are according to the IS.

2. Content type with multilingual settings 'enabled': All three language settings are according to the IS.

3. Content type with multilingual settings 'enabled, with translation': All three language settings are according to the IS.

4. Content type with multilingual settings 'enabled, with field translation' i.e. Entity Translation

  • 'Default language' was migrated correctly as 'Interface text language selected for page'
  • 'Show language selector' was migrated correctly as enabled.
  • The expected result for 'Enable translation' depends on the Entity Translation settings defined in D7 at admin/config/regional/entity_translation
    • I first tested this so that Comments was not defined as translatable entity type. This test FAILED, the 'Enable translation' was migrated as 'enabled'.
    • I then re-tested this so that Comments was defined as translatable entity type. The 'Enable translation' was migrated as 'enabled' as expected.
    • I also updated the IS to be more explicit on this.

5. Other review comments for the patch.

+++ b/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentCommentSettingsTest.php
+  /**
+   * Tests migration of content language settings.
+   */
+  public function testLanguageCommentSettings() {

Should be 'Tests migration of comment language settings.'

6. When testing this issue, I got the following migration error:

  • 'Operation on Custom block translations failed'
  • 'Migration failed with source plugin exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'your-db-name.i18n_string' doesn't exist: SELECT b.bid AS bid, b.format AS format, b.body AS body, i18n.property AS property, lt.lid AS lid, lt.translation AS translation, lt.language AS language, b.info AS title FROM @block_custom b LEFT OUTER JOIN @i18n_string i18n ON i18n.objectid = CAST(b.bid as CHAR(255)) LEFT OUTER JOIN @locales_target lt ON lt.lid = i18n.lid WHERE (lt.lid IS NOT NULL) AND (i18n.type = :db_condition_placeholder_0) ORDER BY b.bid ASC; Array ( [:db_condition_placeholder_0] => block )'

I re-ran my D7 migration also without the latest patch applied (i.e. current 8.7.x) and as I expected, this error was not caused by this patch. Does this ring a bell to anyone and do we already have an issue opened to address this error?

Cheers,
Markus

quietone’s picture

5.6. This is a recent bug. It was first reported by jhodgson first reported it in 2859297 Comment 46. Fortunately, it is an easy fix and the patch is ready for review in #3035259: Unknown column 'lt.i18n_status' in 'field list'.

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

Status: Needs work » Needs review
FileSize
11.65 KB

Needs a reroll

quietone’s picture

The new process plugin ContentTranslationEnabledSetting.php wasn't getting the correct value for entity translation mode. That is corrected now by testing for empty instead of array_key_exists. This includes a new test, with a terribly long name, that uses MigrateDumpAlter to change the variable entity_translation_entity_types so that comment type is disabled. There is a fail patch showing the problem.

And the migration has moved to content translation module because of a discussion in the d6 version of this migration, #2981393: Migrate D6 comment type language settings. See comment 80.

Status: Needs review » Needs work

The last submitted patch, 9: 3024460-9-fail.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review

It is the fail patch that failed, setting to NR

heddn’s picture

Status: Needs review » Needs work

Almost there.

  1. +++ b/core/modules/content_translation/migrations/d7_language_content_comment_settings.yml
    @@ -0,0 +1,63 @@
    +# Ignore i18n_node_options_[node_type] options not available in Drupal 8,
    +# i18n_required_node and i18n_newnode_current
    

    I commented in another issue about this. This should be removed. I think.

  2. +++ b/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentCommentSettingsNoEntityTranslationTest.php
    @@ -0,0 +1,116 @@
    +   * Tests migration of content language settings.
    

    Still needs addressed from earlier (#5.5).

quietone’s picture

Issue summary: View changes
Status: Needs work » Postponed
quietone’s picture

Issue summary: View changes
Status: Postponed » Needs work
quietone’s picture

Status: Needs work » Needs review
FileSize
1.32 KB
16.4 KB

Rerolled the patch since #3022137: Update migrate fixtures for remaining active issues was committed and then, since they are small changes, made the fixes per #12.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Thanks for working on this. This looks good to me other than naming things :D

+++ b/core/modules/content_translation/migrations/d7_language_content_comment_settings.yml
@@ -0,0 +1,61 @@
+id: d7_language_content_comment_settings
+label: Drupal 7 language content comment settings

+++ b/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentCommentSettingsTest.php
@@ -0,0 +1,98 @@
+ * Tests migration of language comment settings.

These are about "Drupal 7 comment language settings" no? Language of comments. "Content" is superfluous as you can only comment on content.

Same for the ID, it would be "d7_comment_language_settings" or somesuch no? Or does that need to follow naming pattern of d7_language_...? (If so, then keep the ID as is IMHO).

Gábor Hojtsy’s picture

Status: Needs work » Reviewed & tested by the community

Hm I see these naming schemes are just consistent with the previously created #2981393: Migrate D6 comment type language settings so this should be fine as-is.

alexpott’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed f3216900b1 to 8.8.x and 17c9135b8e to 8.7.x. Thanks!

  • alexpott committed 17c9135 on 8.7.x
    Issue #3024460 by quietone, Gábor Hojtsy, masipila, heddn: Migrate D7...

  • alexpott committed f321690 on 8.8.x
    Issue #3024460 by quietone, Gábor Hojtsy, masipila, heddn: Migrate D7...

Status: Fixed » Closed (fixed)

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