Problem / motivation

Drupal 7 has a contributed module Entity Translation which allows to have field level translations on fieldable entities. This capability has moved to core in Drupal 8.

The scope of this issue is

  • Migrate the actual translated data of the taxonomy term fields.

Remaining tasks

  • Write the patch
  • Review
  • Commit

Comments

maxocub created an issue. See original summary.

maxocub’s picture

Title: Migrate Drupal 7 taxonomy terms entity translations data to Drupal 8 » Migrate Drupal 7 taxonomy term entity translations data to Drupal 8

Fixed typo in title.

maxocub’s picture

Adding relation to meta.

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

StatusFileSize
new40.79 KB
new15.31 KB
maxocub’s picture

StatusFileSize
new26.37 KB
new28.51 KB
maxocub’s picture

Status: Postponed » Needs work
StatusFileSize
new28.48 KB

Un-postponed and re-rolled since #2669984: Migrate Drupal 7 user entity translations data to Drupal 8 landed. Left on NW to verify that the test coverage is enough.

masipila’s picture

Queued for PostgreSQL and SQLite tests. I gave the patch a first quick round of eyeballs and it looks nice! I will test it and read it again possibly tomorrow.

Markus

mradcliffe’s picture

+    $query = $this->select('entity_translation', 'et')
+      ->fields('et')
+      ->fields('td', [
+        'name',
+        'description',
+        'format',
+      ])
+      ->fields('tv', [
+        'machine_name',
+      ])
+      ->condition('et.entity_type', 'taxonomy_term')
+      ->condition('et.source', '', '<>')
+      ->distinct()
+      ->orderBy('tid');

This should be solved by adding tid to the "td" fields above.

maxocub’s picture

StatusFileSize
new779 bytes
new28.4 KB

It also fails on PHP 5.6. Looking at this, I don't think we need the distinct() and orderBy() calls.

maxocub’s picture

Status: Needs work » Needs review
StatusFileSize
new6.38 KB
new31.7 KB

New patch that replace the hardcoded 'en' langcode by the site's default language if the entity source language is not found.
Also added test for the description format.
I think it's now ready for reviews.

masipila’s picture

Status: Needs review » Needs work

I made quite extensive manual testing, inspecting the results in UI and in the database.

1. Bug: The publishing status is not mapped and thus D8 term translations are always 'published' even if the D7 translation is 'not published'.

2. Nit: Class description must start with a third person verb.

diff --git a/core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php b/core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php
new file mode 100644
index 0000000000..c417764339
--- /dev/null
+++ b/core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php
@@ -0,0 +1,122 @@
+<?php
+
+namespace Drupal\taxonomy\Plugin\migrate\source\d7;
+
+use Drupal\migrate\Row;
+use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
+
+/**
+ * Taxonomy term entity translation source from database.

3. Nit: I think we used uppercase ID in other entity translation source plugins

+  public function fields() {
+    return [
+      'entity_id' => $this->t('The entity id this translation relates to'),
+      'revision_id' => $this->t('The entity revision id this translation relates to'),
+    ];
+  }

4. Test coverage MigrateTaxonomyTermTest.php
Could we please have test coverage for other metadata properties as well?

Cheers,
Markus

maxocub’s picture

Status: Needs work » Needs review
StatusFileSize
new4.27 KB
new31.92 KB
  1. Fixed, added the status in the migration file.
  2. Done.
  3. Done.
  4. I added assertions for isPublished() and getChangedTime(), did you had anything else in mind?
masipila’s picture

That was super fast response @maxocub!

I reviewed #14. All feedback is addressed so this is RTBC once the tests (that are currently running) are green.

My evening practice is starting soon so it would be good if somebody can switch the status after the tests have finished so that we can get this to Gabor's final review queue ASAP during our mini-sprint week.

Thanks once more @maxocub!

Cheers,
Markus

masipila’s picture

Status: Needs review » Reviewed & tested by the community

The tests turned out to be green as expected, RTBC.

gábor hojtsy’s picture

I think this looks great. I got blocked to commit this by my local dev environment blown away with the Mac Mojave upgrade. If another committer gets to this sooner, please commit :)

  • catch committed e5a4531 on 8.7.x
    Issue #2980996 by maxocub, masipila, mradcliffe, Gábor Hojtsy: Migrate...
catch’s picture

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

Committed/pushed to 8.7.x and cherry-picked to 8.6.x. Thanks!

  • catch committed 7eda775 on 8.6.x
    Issue #2980996 by maxocub, masipila, mradcliffe, Gábor Hojtsy: Migrate...

Status: Fixed » Closed (fixed)

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