Problem/Motivation

Follow-up to #2975666: Migrate Drupal 7 node entity translations data to Drupal 8.

When using the Entity Translation module in Drupal 7, most users were forced to enable the Title module to transform the title into a field which could then be translated. As such we should support the migration of this module's data.

Proposed resolution

Since the this module's replacement title field is a real field, the field config and field values are already migrated by the existing migrations. Even better, the translations are also migrated when using the patch from #2975666: Migrate Drupal 7 node entity translations data to Drupal 8.

What we still need to do is to skip the migration of this title field and map it's value to the node's title.

Other than nodes' title, this module also allow to replace the comments' subject and the terms' name and description by real fields.

Remaining tasks

  • Write the patch
  • Review
  • Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcnventura created an issue. See original summary.

mikeryan’s picture

Priority: Major » Normal

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.

heddn’s picture

Priority: Normal » Major

Let's at least bump to major from normal. Not sure if this should be 'Migrate Critical'.

masipila’s picture

Tagging with Migrate critical and Migrate Drupal according to the policy discussion for Migrate Drupal stability criteria.

This functionality was in contrib in D7 but the capability is provided by core in D8.

maxocub’s picture

Status: Active » Postponed

Since the Title module exploits entity_translation to work, this issue should be postponed until we fix #2073467: Migrate Drupal 7 Entity Translation settings to Drupal 8. It may be resolved in that issue since the title module only transform the title into a normal field.

Feuerwagen’s picture

Feuerwagen’s picture

Status: Needs work » Active
maxocub’s picture

Status: Active » Postponed
Related issues: +#2975666: Migrate Drupal 7 node entity translations data to Drupal 8

Sorry but that fixed issue has been re-scoped to only deal with Entity Translation settings, so we're not quite ready to work on migrating Title data. We'll need to wait until the migration the actual translated data is supported: #2975666: Migrate Drupal 7 node entity translations data to Drupal 8.

maxocub’s picture

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.

maxocub’s picture

Assigned: Unassigned » maxocub
Status: Postponed » Active

This does not have to be postponed on #2975666: Migrate Drupal 7 node entity translations data to Drupal 8. The Title module is not tied to the Entity Translation module.
I'm working on a patch.

maxocub’s picture

Issue summary: View changes

IS update.

maxocub’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
4.47 KB

Here's a start. I will add tests soon.

maxocub’s picture

Status: Needs review » Postponed
Issue tags: -Needs tests
FileSize
63.72 KB
97.42 KB
68.2 KB

After pondering about this issue, I decided to put it back on postponed. Since the primary use of the Title module is with combination with the Entity Translation module, we should wait for the ET patch to land so we can add tests for the migration of title translations.

I included a patch combined with the latest patch from #2975666: Migrate Drupal 7 node entity translations data to Drupal 8, if people want to use it and test it.

masipila’s picture

I read the patch (did not test it manually yet).

+++ b/core/modules/field/migrations/d7_field.yml
@@ -14,7 +14,20 @@ process:
   entity_type: entity_type
   status: 'constants/status'
   langcode: 'constants/langcode'
-  field_name: field_name
+  # Skip the fields created by the Drupal 7 Title module.
+  field_name:
+    -
+      plugin: static_map
+      map:
+        title_field: null
+        name_field: null
+        description_field: null
+        subject_field: null
+      bypass: true
+      source: field_name
+    -
+      plugin: skip_on_empty
+      method: row

Does this mean that if a source site had a manually created field called 'description_field', it would be ignored?

The patch checks in several places simply for presence of title_field / description_field / name_field / subject_field. Is it so that we don't have any setting flag that could be used to explicitly check if Title module is used in that context?

If not, then I guess this is the best what we can do. It just feels like quite big assumption to always assume that for example description_field should be interpreted as an override of description. The good part that makes this somewhat less risky is the fact that the machine names of manually created fields typically have a 'field_' prefix.

Markus

maxocub’s picture

You're right, we should definitely check if the Title module was enabled on the source. It is possible for someone to have created a field named 'title_field' programmatically, but if the Title module was enabled, then they would had have conflicts. I think we can safely assume that if there's a 'title_field' and that the Title module is enable, then the field is the one created but said module.

Here's a new approach.

masipila’s picture

Yay! I find this approach much more elegant.

I'll test this over the weekend.

Markus

Gábor Hojtsy’s picture

maxocub’s picture

Assigned: maxocub » Unassigned
Status: Needs work » Needs review
FileSize
4.6 KB
16.55 KB
68.58 KB

Here's a re-roll with a few improvements. It would be such a win to get this in 8.6 since most of the people who used Entity Translation also used Title.

Status: Needs review » Needs work

The last submitted patch, 21: 2863437-21.patch, failed testing. View results

maxocub’s picture

Status: Needs work » Needs review
FileSize
2.47 KB
18.09 KB
70.12 KB

Let's turn those tests to green.

maxocub’s picture

The last submitted patch, 23: 2863437-23.patch, failed testing. View results

masipila’s picture

Queued for PostgreSQL and SQLite tests. I'll find time to test this today.

masipila’s picture

Status: Needs review » Needs work

I reviewed the patch #24 and tested it manually.

Test setup in D7

1. Positive tests - Article configuration in D7

  • Content type Article has has multilingual settings as 'Enabled, with field translation' (i.e. D7 contrib Entity Translation module)
  • Article title field has been replaced with a field provided by the Title module.
  • Article has comments enabled, comment subject has been replaced with a field provided by the Title module.
  • Article has two vocabularies. Vocabulary 'tags' has name and description replaced with fields provided by the Title module.

2. Negative tests - Article configuration in D7

  • As mentioned above, Article has two vocabularies. Vocabulary 'vocabulary_2' does **not** have name and description replaced with the D7 Title module.

3. Negative tests - Content type 'node_translation' configuration in D7

  • Content type 'node_translation' has multilingual settings as 'Enabled, with translation' (i.e. D7 core content translation module)
  • Title of this content type has **not** been replaced with D7 Title module.
  • This content type has comments enabled but comment subject has **not** been replaced with D7 Title module.
  • This content type has a vocabulary 'vocabulary 2'. This vocabulary does **not** have name and description replaced with D7 Title module.

4. Negative tests - Content type 'monolingual' configuration in D7

  • Content type 'monolingual' does not have multilingual options enabled.
  • Title of this content type has **not** been replaced with D7 Title module.
  • This content type has comments enabled but comment subject has **not** been replaced with D7 Title module.
  • This content type has a vocabulary 'vocabulary 2'. This vocabulary does **not** have name and description replaced with D7 Title module.

Manual test content and test results

1 and 2: Positive and negative Article tests

  • One node had original in EN and field level translation to FI.
  • One node had original in FI and no (field level) translations to EN.
  • One node had original in EN and no (field level) translations to FI.
  • One node was language neutral (und) without translations.
  • One node had original in FI and field level translation to EN.
  • Several nodes had comments.
  • Taxonomy terms in vocabulary 'tags' were present on several nodes.
  • Taxonomy terms in vocabulary 'vocabulary_2' were present on several nodes. Some of them in the same node as where 'tags' were used.
  • Revisions were tested.

All tests passed:

  • Node titles appeared as expected on both view and edit form.
  • Node revision titles appeared as expected.
  • Comment titles appeared as expected on both view and edit form.
  • Term titles and descriptions appeared as expected on both view and edit form for both 'tag' and 'vocabulary_2' terms.
  • The term translations that were translated using Entity Translation were not migrated properly because the following issue has not landed yet, see #2980996: Migrate Drupal 7 taxonomy term entity translations data to Drupal 8. The taxonomy term translations are not in the scope of this Title migration issue so the test result here is as expected.

3. Negative tests - Content type 'node_translation'

  • One node had original in FI and translated on node level to EN.
  • One node had original in EN and translated on node level to FI.
  • One node was language neutral.
  • Comments were added to the original language of a node.
  • Taxonomy terms in vocabulary 'vocabulary_2' were present.

All tests passed:

  • Node titles appeared as expected on both view and edit form.
  • Comment titles appeared as expected on both view and edit form.
  • Term titles and descriptions appeared as expected on both view and edit form for 'vocabulary_2' terms.

4. Negative tests - Content type 'monolingual'

  • One node with a comment and term of vocabulary_2, with revisions

All tests passed:

  • Node title appeared as expected on both view and edit form.
  • Node title appeared as expected on revision
  • Comment titles appeared as expected on both view and edit form.
  • Term titles and descriptions appeared as expected on both view and edit form for 'vocabulary_2' terms.

Conclusion from manual tests

  • The coverage of the manual tests included all aspects of the Title migration that I could think.
  • The coverage of the manual tests exceeded the scope of this issue as I wanted to verify that this works as expected with #2975666: Migrate Drupal 7 node entity translations data to Drupal 8 which is the primary use case of the D7 Title module.
  • All manual tests passed.
  • There were similar issues with node revisions as reported in 2746541#24-27 but those issues are not in the scope of this Title migration.

Patch review comments

My earlier feedback in #17 was addressed already earlier. Ok.

When I started to do my manual tests, I was concerned about the behavior when the Title 'replace' has been set on one content type while some other content type has not the title 'replace' enabled. The test results were OK as stated above. This gotcha is handled as follows in the source plugin like this:

+    // If the node title was replaced by a real field using the Drupal 7 Title
+    // module, use the field value instead of the node title.
+    if ($this->moduleExists('title')) {
+      $title_field = $row->getSourceProperty('title_field');
+      if (isset($title_field[0]['value'])) {
+        $row->setSourceProperty('title', $title_field[0]['value']);
+      }
+    }

We are overriding the standard title only if a) the Title module exists AND b) title_field[0]['value'] is set. This is a very elegant way IMO to handle the scenario where some content types have the replacement enabled and others not. This is by far more elegant compared to a situation where we would do the if statement by checking the content type's 'replace' setting because this approach that @maxocub used is 100 times easier to maintain. @maxocub++.

Review of test coverage:

  • Node and node revision title handling seems to be covered.
  • If I'm not mistaken, we don't have test coverage for term name / description handling.
  • If I'm not mistaken, we don't have test coverage for comment title handling.

Kicking back for term name / description + comment title test coverage. If those were there already, please highlight those to me as a comment and I will re-review from my mobile.

Cheers,
Markus

Edit: Typos

maxocub’s picture

Here's some full migration tests and plugin tests for comment subject fields and taxonomy term name and description fields. Thanks for noticing those missing tests!

masipila’s picture

Hi!

Test coverage looks good to me now. According to the interdiff, all changes in this latest patch are test related so my manual test results are still valid.

I queued PostgreSQL and SQLite tests as well. Let's see what the testbot has to say about this latest patch.

Markus

masipila’s picture

Status: Needs review » Reviewed & tested by the community

Tests with the improved coverage are green. Manual tests are all green, see #27. I've reviewed the patch and feedback has been addressed. RTBC.

It would be superb if this could be committed to the same release as #2975666: Migrate Drupal 7 node entity translations data to Drupal 8.

Cheers,
Markus

  • Gábor Hojtsy committed 242b03d on 8.7.x
    Issue #2863437 by maxocub, masipila: Migrate Drupal 7 title data to...

  • Gábor Hojtsy committed 3e7c82e on 8.6.x
    Issue #2863437 by maxocub, masipila: Migrate Drupal 7 title data to...
Gábor Hojtsy’s picture

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

Looks good, thanks! I've been pondering a bit that we only added entity translation migrations for nodes so far, so having title migration support for others would be running ahead of ourselves, but there is no reason to not to do them here.

Status: Fixed » Closed (fixed)

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