Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Follow-up to #2975666: Migrate Drupal 7 node entity translations data to Drupal 8. In another follow-up (#2669984: Migrate Drupal 7 user entity translations data to Drupal 8), we found that we missed 3 things:
- The
d7_node_entity_translation
migration should not be in the Node module but in the Content Translation module. This is true since the new module Migrate Drupal Multilingual was introduced in #2953360: Experimental migrate_drupal_multilingual module. - We missed one entity translation metadata that we should have mapped,
content_translation_outdated
. - We missed tow migration dependencies:
language
&d7_entity_translation_settings
.
Proposed resolution
- We should move the
d7_node_entity_translation
migration to Content Translation, with all the other multilingual migrations. - We should map the missing entity translation metadata.
- We should add the missing migration dependencies.
Remaining tasks
- Write the patch
- Review
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#33 | 2989627-33.patch | 14.83 KB | maxocub |
#33 | interdiff-2989627-29-33.txt | 2.23 KB | maxocub |
Comments
Comment #2
maxocub CreditAttribution: maxocub for Acquia commentedHere's a first patch.
Comment #4
maxocub CreditAttribution: maxocub for Acquia commentedComment #5
maxocub CreditAttribution: maxocub for Acquia commentedBack to NR.
Comment #6
maxocub CreditAttribution: maxocub for Acquia commentedIS update.
Comment #7
maxocub CreditAttribution: maxocub for Acquia commentedFix IS typos.
Comment #8
masipila CreditAttribution: masipila as a volunteer commentedTest tested this manually and analyzed node_field_data database table.
1. Translation outdated ('content_translation_outdated') property is now correctly migrated. OK.
2. Migration dependencies for 'language' and 'd7_entity_translation_settings' have now been added as described in the IS.
3. I also did manual regression testing, all OK.
4. Question:
D8 node_field_data table has a column 'revision_translation_affected'. What is this property? We are not mapping it here. Will that be part of some other issue, such as #2746541: Migrate D6 and D7 node revision translations to D8?
5. I reviewed test coverage for the source plugin, OK
6. I reviewed test coverage for MigrateNodeTest, NOT OK
Here are the asserts:
We don't have tests for
Could we please have test coverage for default_langcode, content_translation_source and content_translation_outdated? Kicking back to NW for those.
Cheers,
Markus
Comment #9
maxocub CreditAttribution: maxocub as a volunteer commentedThanks for the review @masipila.
4. About 'revision_translation_affected', I really don't know how that property works exactly, and even less how and if we can migrate it. Here's some info I found about it:
From
system_install()
:And from
entity.api.php
:If we think it can and should be migrated, we should open a follow-up.
6. About the test coverage in MigrateNodeTest, I added asserts for the default translation, the source langcode and the translation outdated. I converted the Entity Translation tests to use the helper method
assertEntity()
, even though I find it less readable than with some code repetition like it was before.Comment #10
phenaproximaI think @plach would be better qualified to weigh in on this authoritatively, but I believe revision_translation_affected is a completely internal field, used by the translation system, and should not be touched by us if we can at all avoid it.
This could benefit from a comment explaining what this mapping is for. It's not at all obvious, and this is the sort of obscure sorcery that could come back later to bite us in the ass.
Why did this change?
'id' should be 'ID'.
I agree with @maxocub that this stuff shouldn't be in assertEntity(). We are dangerously close to over-abstracting the assertions; in tests, it's okay to repeat some code like this.
Comment #11
maxocub CreditAttribution: maxocub as a volunteer commentedThanks for the review @phenaproxima! Back to NW.
Comment #12
maxocub CreditAttribution: maxocub commentedRe #10:
d7_node_entity_translation
migration (language
&d7_entity_translation_settings
) it will now be run afterd7_node_translation
.Comment #13
quietone CreditAttribution: quietone at Acro Commerce commentedReading the patch I see that all the changes in #10 have been addressed.
I haven't read the whole issue but see that phenaproxima suggested speaking to plach about #9.4. Is that still needed ?
Comment #14
maxocub CreditAttribution: maxocub commented@quietone: I don't think it's needed anymore. After playing with that field I'm pretty convinced that we should not migrate.
Comment #15
phenaproximaOkay, so...let's just remove revision_translation_affected from the migration and see if any tests break. If they don't, great! If they do, we should understand exactly why they break and be able to justify to @plach why we should migrate that field.
Comment #16
maxocub CreditAttribution: maxocub as a volunteer commentedBut,
revision_translation_affected
is not currently migrated. I don't even think there's an equivalent in D7 to migrate it from.Comment #17
masipila CreditAttribution: masipila as a volunteer commentedPeekaboo, getting back to this issue after a while.
I tested this manually in #8. The changes in #9 (after my review) and #12 (after @phenaproxima's review) are so minor that my manual test results are still valid.
The only remaining topic that has been discussed is the D8 'revision_translation_affected' property. I did some research on this as well and came to the same conclusion with @maxocub in #16. There is no equivalent property in D7 as far as I can tell. The current patch does not map this property, which is correct behavior.
Triggering the testbot for PostgreSQL and SQLite. Once those are green, this is RTBC.
Cheers,
Markus
Comment #18
heddnPer #17, moving to RTBC.
Comment #19
Gábor HojtsyDoes not apply to Drupal 8.7 currently:
Comment #20
maxocub CreditAttribution: maxocub as a volunteer commentedRe-roll done.
I took the liberty to make one change (see the interdiff) to the Node source plugin so it handle the source language the same way as the Comment, Term & User source plugins.
Comment #21
Gábor HojtsyHm, you made this slight logic change but no tests failed and no tests needed to be updated. Looks like if there was no entity translation source language on the node the behaviour would be now different?
Comment #22
masipila CreditAttribution: masipila as a volunteer commentedRe-parented so that all remaining multilingual migration issues can be found from the same meta. Moved the previous parent issue to related issues.
Comment #23
masipila CreditAttribution: masipila as a volunteer commentedRe #21. I cross checked what we have in the other Entity Translation source plugins.
Proposed code (from #21) for the Node source plugin that is being discussed here:
User source plugin:
Taxonomy term source plugin:
Comment source plugin:
The determination of
$language
is consistent.@maxocub: I did not have time on the gate to check this but why do we have
$row->setSourceProperty('language', $language);
in user and taxonomy term source plugins but not in node and comment source plugins?Cheers,
Markus
Comment #24
maxocub CreditAttribution: maxocub as a volunteer commentedRe #21: You're right, this needs a test. I think that when you use Entity Translation you will always have a source language in the
entity_translation
table, unless you messed with it. I added this extra logic because when I was writing the current tests I messed up my DB. While it should not really happen, I agree we need a test.Re #23: For Node and Comment we don't need the
$row->setSourceProperty('language', $language);
because we already have a language property from the D7 table to migrate from.The D7 taxonomy_term table does not have a language column so we need to set it.
The D7 User table does have a language column, but we already use it to determine the
preferred_langcode
andpreferred_admin_langcode
, so we need to do set theentity_language
source property to set the D8 user langcode without affecting the user's preferred langcodes.Comment #25
maxocub CreditAttribution: maxocub commentedI added a failing test for when the source language is missing from the entity_translation table.
Comment #27
quietone CreditAttribution: quietone at Acro Commerce commented@maxocub, Just took a wee look and I have a question.
This looks like the source language. What field is supposed to be missing?
Comment #28
maxocub CreditAttribution: maxocub commentedYou're right, the comment is misleading. What is missing from the entity_translation table is the source language node. The source language node is the entry with the 'source' => ''. All entries with 'source' => 'en' are translations of the English (source language) node.
Comment #29
maxocub CreditAttribution: maxocub commentedI updated the misleading comment.
Comment #30
quietone CreditAttribution: quietone as a volunteer commentedThanks. I still have trouble understanding what is missing.
So, for the first time, I used entity translation with the test fixture. It took a while but I was finally getting new entries in the entity_translation table. So, when I make a new node a row is added to that table with the source language property empty. When that node is translated a new row is added with language = fr and source = en. Which is correct the source was English and the translation was French.
So, from that, I think what it meant by missing in the comment is that the row where language = the first language used, and the source is empty is what is missing. That is a row in the table is missing not that the property source is missing. Is that right?
Comment #31
maxocub CreditAttribution: maxocub as a volunteer commentedYes, your understanding is right. I have a hard time finding a comment that would be more clear. Do you have any suggestions?
Comment #32
quietone CreditAttribution: quietone as a volunteer commentedPhew, glad I got that right. As for a suggestion, let's see.
The source data with a row missing from the entity_translation table. There should be a row where the language property is set and the source property is empty.
How about that?
Hmm, may be better to have two tests? Would it make sense to modify tests[1] to have that extra row and then make tests[2] the same as the current tests[1]? The first could have a comment 'Test with a correct entity_translation table' and then test[2] could be 'Repeat the previous test with an incorrect entity_translation table where the row with source property is empty is missing'.
Currently leaning to the second suggestion.
Comment #33
maxocub CreditAttribution: maxocub as a volunteer commentedI agree with your 2nd suggestion, here it is.
Comment #34
quietone CreditAttribution: quietone as a volunteer commented@maxocub, thanks for working through this. It is really clear and obvious what is going on in the test now.
Since the last RTBC there have been questions which have all been answered and the need for a new test was discovered. That test was added and then another test was added with comments to make it clear what a 'good set' of source data looked like and a 'bad set' of source data.
Back to RTBC!
Comment #36
Gábor HojtsyThanks for adding a test for the logic improvement, looks much better now.