Closed (fixed)
Project:
Drupal core
Version:
8.6.x-dev
Component:
migration system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 May 2018 at 22:42 UTC
Updated:
10 Aug 2018 at 19:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
maxocub commentedPostponed on #2073467: Migrate Drupal 7 Entity Translation settings to Drupal 8.
Comment #3
maxocub commentedUnpostponed.
Comments #12 and #14 of parent issue contains hints on how to do this (for nodes at least).
Comment #4
maxocub commentedI'm working on it this afternoon. I hope to have a patch soon.
Comment #5
maxocub commentedThis is a start. Let's see how much tests it breaks.
Comment #6
maxocub commentedFixing the tests and adding support for migrating comment fields.
This will need tests, but it's late now.
Comment #7
maxocub commentedSince the 4 source plugin use almost the same code to join the entity_translation table, let's put that in a method on FieldableEntity.
Comment #8
maxocub commentedI asked @jigarius to leave a comment here because the blog article he wrote was very helpful in writing this patch. I insist that he is given credit on this issue.
Comment #9
jigariusYo! This issue looks great! Thanks maxocub for telling me about this issue.
Comment #10
maxocub commentedI started adding tests for this issue, but hit several walls. I realised that trying to support all 4 entity types in one patch is way too complex.
Beside that, there's the comment fields that are not getting migrated at all, so I cannot migrate field translations without them, I opened an issue for that: #2979916: D7 comment field values are not migrated.
I'm going to rescope this issue for only node entity translations, and I'll open follow-ups for comments, terms & users.
Comment #11
maxocub commentedCreated follow-ups:
Comment #12
masipila commentedI swapped the parent and related issue so that this can be found easier on the meta issue. I'll add the three follow-ups to the meta as well.
Comment #13
nchase commentedApplied the patch in #7. Can't see that any entity translations for nodes got imported.
Comment #14
maxocub commented@Nchase: The patch is not ready yet, I'm working on it.
Comment #15
maxocub commentedHere's a new patch that I think is ready for some manual testing.
No interdiff since there's too much changes.
Comment #17
maxocub commentedThis should fix the failures.
Comment #18
phenaproximaLooks pretty good to me. I only have a few small requests.
Changing this adds a bunch of patch noise. In the interest of making this even easier to review, can we revert this change?
$bundle is never used in this method, so let's remove it.
We're assuming the entity_translation table exists, and that's a big "if". We should probably add some sort of safeguard or checking here.
Nit: We could chain these calls to everything else:
return $this->select()->fields()->condition()->execute()->fetchField().Nit: Over 80 characters.
Why did this change?
Comment #19
maxocub commentedComment #20
masipila commentedSelf-assigning for testing and review.
Comment #21
masipila commentedI tested this manually.
Drupal 7 setup
I have three languages enabled: EN (default), FI, SV
I have three content types: Article, Page and Forum (I included Forum in our tests since it has the hard coded special handling in migrations)
Content type language settings:
Article setup:
Forum setup:
Test content
Forum nodes:
Article nodes:
Page nodes:
Test results
Forum nodes
Test failures for Forum node 3 and Forum node 4:
Article nodes
Page nodes
Conclusion
Comment #22
maxocub commented@masipila: Thanks for your detailed manual testing, as always.
I tried to reproduce the problem you mention with forum by using the exact same D7 setup, but in my tests the translations of Forum fields are migrated, even if the source language is not the default English.
I'll try to understand what's happening.
Comment #23
maxocub commentedI made more manual testing and I cannot reproduce the problems with Forum mentioned in #21.
Comment #24
masipila commentedI managed to find the root cause for the issue reported in #21. It is a bug in D7, not in this migration.
Here's the proof that it is an issue in the source data quality and not in the migration.

Node 8 in the D7 is of type Forum. There is only a FI language version of this node, but the body value language is EN in the database.
Node 9 in the D7 is of type Article. Also this node has a FI language version but here the language of the body value is saved correctly.
Our migration can't do any assumptions and try to guess language codes so we can't start changing the language codes that the source database is indicating.
All feedback has been addressed. @phenaproxima and I have reviewed the patch. There is test automation coverage and my manual tests were all OK except this Forum issue where the bug is on the D7 source side and we can't do anything about it in the migration.
RTBC. These Entity Translation migrations are pretty heroetic stuff @maxocub, well done! Reminder to committers to also credit @jigarius whose blog post heavily influenced this patch.
I'll raise a bug to Entity Translation issue queue on the D7 bug.
Cheers,
Markus
Comment #26
masipila commentedwooooot, the tests were green already?
The D7 ET issue is here: #2986068: Incorrect field language codes for Forum content type
Comment #27
maxocub commentedNeeded a re-roll. Here it is.
Comment #28
benjifisherI have been fighting with a D7 -> D8 migration, and finally decided that either my D7 site is borked or there is a bug in FieldableEntity. Then I found this issue ...
I am still not sure whether my D7 site is borked, but I wonder about this change:
What is the significance of 4 for the
language_content_type_*variables? They all seem to be set to 2 on my D7 site. That means ...$entity_translatableisFALSE$languageis$row->getSourceProperty('language')(what I want)$field_languageisNULL(not what I want)Comment #29
maxocub commentedWhen a
language_content_type_*variable is set to '4', that means that this content type is using Entity Translation, so translation at the field level. If your content types are all set to '2', that means that you are using i18n translation. I18n translations are at the node level, and are supposed to work without this patch. Their field are stored with the default language for their langcodes. So FieldableEntity::getFieldValues() should not have a $field_language. This patch is not supposed to affect migrations of nodes translated with i18n.Comment #30
masipila commented@maxocub would it be possible to get an 19-27 interdiff?
Comment #31
quietone commented@masipila, I think there is something here that should be documented, perhaps on Known Issues, or a page just for Multiligingual. Obviously, there is the bug to mention but the summary in #29 is really nice (thanks maxocub) and may help migraters in the future who may not know the details of the translation methods.What do you think?
@maxocub and @masiplia thanks for working on this during your holidays!
Comment #32
benjifisher@maxocub: Thanks for the explanation. I am leaning towards the theory that my site is borked.
@masipila: I have attached an interdiff for 19-27.
Comment #33
masipila commentedTests are now green again after the reroll. I added also PostgreSQL and SQLite tests which passed.
According to interdiff 19-27 (thanks @benjifisher!) my earlier manual test results are still valid.
Back to RTBC.
What comes to the handbook docs, I'm about to write a similar page to multilingual D7-D8 upgrades as we already have for D6-D8 and that will address #31. I don't think we should postpone this on that handbook page so I'm removing the doc tag.
Cheers,
Markus
Comment #34
jcnventuraTested this. Looks pretty good. I've got ~1500 nodes that got correctly migrated from D7 to D8 with source language 'pt-pt' and 'en' translation. In D8, the 'en' translations are now present. Good job @maxocub
The only (minor) comment is that some of us also used the 'title' module to translate the titles, and that is still not supported here.
Comment #35
maxocub commented@jcnventura: Thanks for testing this patch! We have a follow-up for the Title module #2863437: Migrate Drupal 7 title data to Drupal 8 which will be my priority once this patch lands.
Comment #37
jcnventuraThis applies to the 'migrate_drupal' experimental module. It can safely go into 8.6. We shouldn't need to wait 6 months for this important improvement to the D7 -> D8 migration path.
Comment #38
maxocub commentedSorry about putting this back to NW, but I'm not 100% satisfied with it yet. I think the code can benefit from some inline comments. And also, I think that the NodeEntityTranslation source plugin should not extend Node source plugin. It should extend FieldableEntity and thus be able to call parrent::prepareRow() and benefit from SourcePluginBase::prepareRow().
I think I can provide a new patch today.
Comment #39
maxocub commentedI did what I mentioned in #38. Added a few comments, extended FieldableEntity instead of Node.
Comment #40
masipila commentedGrammatic nit from a first quick glance at the interdiff. I'll still have a closer look at this either this evening or tomorrow.
/s/it's/its
Markus
Comment #41
maxocub commentedFixed the typo.
Comment #42
masipila commentedI now had a chance to have a closer look at the improvements #39 and read the whole patch #41 once more.
Extending from FieldableEntity instead of Node make sense to me. A couple of suggestions for the inline comments.
1.
Maybe this would flow better: Join the 'field_config' table and add the 'translatable' setting to the query.
2.
The comment is implying that there would be two conditions but the code itself is only checking if $language is set. Suggestion: Add language as a query condition if it has been defined by Entity Translation.
3.
Method description should start with a third person verb. In addition, we're using 'Entity Translation' instead of 'entity translation' elsewhere.
4.
Ditto.
5.
I find the inline comment a bit confusing since we are not adding any conditions here directly (the underlying query and its condition is an implementation detail of getFieldValues()).
Maybe this would flow better: Ensure we're using the right language if the entity and the field are translatable.
6.
Class description must start with third person verb. In addition, we're using 'Entity Translation' instead of 'entity translation' elsewhere.
7.
Same comment as 5. Maybe this would flow better: Ensure we're using the right language if the entity is translatable.
8.
/s/entity translation/Entity Translation
Comment #43
maxocub commentedComment #44
masipila commentedRTBC once the tests are green.
Comment #46
maxocub commentedThe failing test needed an update since #2985716: Cannot save language negotiation settings after upgrade landed.
Comment #47
masipila commentedAnd the tests are now green. RTBC.
Comment #48
catchThis now needs the 'Multilingual' migration tag I think, so it gets caught by migrate_drupal_multilingual?
Comment #49
maxocub commentedOh, right, it need the tag.
Comment #51
maxocub commentedI'm at work and I'm not able to run this test localy, so I'm totally guessing here, but I think it's because d7_node_entity_translation:article comes before d7_node_translation:article alphabetically. Let's see if I'm wrong.
Comment #52
masipila commentedWas the line break intentional?
Comment #53
maxocub commentedWhat line break? I don't see it.
Comment #54
masipila commentedMaybe it's my mobile browser then. 'd7_node_entity_translation:article' appeared to be on a new line in the interdiff.
Comment #55
masipila commentedTests are back to green and the newline thing in the previous comments was just because the line did not fit to my screen. Back to RTBC.
Comment #58
gábor hojtsyYay, thanks so much for bringing this issue to completion :) The stable changes look fine, eg. the language parameter to the node plugin. Let's fix the followups :)