Problem/Motivation
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 6 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.
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 6 content type has multilingual support 'disabled'.
Drupal 6 fixture: story.
- '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 6 content type has multilingual support 'enabled'.
Drupal 6 fixture: sponsor
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 D6 are independent i.e. the comments are not translations of each other.
3. If the Drupal 6 content type has multilingual support 'Enabled, with translation'.
Drupal 6 fixture: article and employee. .
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 D6 are independent i.e. the comments are not translations of each other.
NOTE: The scope of this issue is D6-D8 only. The D7-D8 migration will be handled in #3024460: Migrate D7 comment type language settings.
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.
Comment | File | Size | Author |
---|---|---|---|
#86 | 2981393-86.patch | 56.57 KB | quietone |
#86 | interdiff-84-86.txt | 791 bytes | quietone |
#84 | 2981393-84.patch | 56.57 KB | quietone |
#84 | interdiff-71-84.txt | 3.5 KB | quietone |
#71 | interdiff-68-71.txt | 1.37 KB | quietone |
Comments
Comment #2
masipila CreditAttribution: masipila as a volunteer commentedComment #3
masipila CreditAttribution: masipila as a volunteer commentedComment #5
quietone CreditAttribution: quietone as a volunteer commentedAdd tag
Comment #6
quietone CreditAttribution: quietone as a volunteer commentedThis should fulfill the solution in the proposed resolution.
Comment #8
quietone CreditAttribution: quietone as a volunteer commentedUpdate the entity counts for MigrateUpgrade6Test.
Comment #10
quietone CreditAttribution: quietone as a volunteer commentedTests pass and there are no coding standard errors, so setting NR
Comment #11
quietone CreditAttribution: quietone as a volunteer commentedThis migration is nearly the same as d6_language_content_settings.yml. What is changed is the source of language_alterable, from i18n_lock_node to language_content_type.
This line can be remove
Comment #12
heddnIs this NW for #11?
Comment #13
quietone CreditAttribution: quietone as a volunteer commentedRemove the unnecessary line, from #11.
Comment #14
maxocub CreditAttribution: maxocub as a volunteer commentedGood work, just a few nits:
I don't see any variables being migrated, maybe we should just say "Tests migration of language content comment settings."?
This method should be rename to something more specific.
We test the same thing twice. Could we test the other language setting?
I never saw this 'migration' count. I often added migrations without having to update this count. I put it back to 105 and ran the test and it passed. I think this line is not necessary.
Comment #15
quietone CreditAttribution: quietone as a volunteer commentedNeeds a reroll
Comment #16
quietone CreditAttribution: quietone as a volunteer commented1. Fixed
2. Fixed
3. Fixed. Thanks I did miss that! Added tests for isLanguageAlterable(). Also changes the tests to use any getters that exist.
4. Interesting. I don't see how it would pass the test when that is changed. If that needs to be removed then it should be a separate issue as it is also in the D7 tests. I'm uploading a test only patch with migrations = 105 instead of 106. Let's see what testbot does with that.
Oh and I ran a full migration and checked that the criteria of the proposed resolution are met.
Comment #18
quietone CreditAttribution: quietone as a volunteer commentedDarn, when I am sick I make even more silly errors. Patch 2981393-16.patch and 2981393-16-test-only.patch are identical and they should not have been but there it is. So, let's just ignore Comment #16 and move on.
And uploading the correct patch so there is no confusion.
14-1. Fixed
14-2. Fixed
14-3. Fixed. Thanks I did miss that! Added tests for isLanguageAlterable(). Also changes the tests to use any getters that exist.
14-4. Interesting. Created a new issue, since this will affect both d6 and d7, to look into why the migration count changes don't cause test failures, #3009137: Migration entity count not tested in MigrateUpgrade Tests
Oh and I ran a full migration and checked that the criteria of the proposed resolution are met.
Comment #19
quietone CreditAttribution: quietone as a volunteer commentedComment #20
masipila CreditAttribution: masipila as a volunteer commentedI tested this with both D6 and D7 even though I can see from the patch #18 that we are only dealing with D6 stuff at the moment.
D6 test setup
D6 test result
D6 1. Drupal 6 content type has multilingual support 'disabled'
D6 2. Drupal 6 content type has multilingual support 'enabled'.
This means that the nodes can have a language code but the different nodes cannot be linked as translations of each other.
D6 3. Drupal 6 content type has multilingual support 'Enabled, with translation'.
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.
D7 Test setup
Content types 1-3 as above for D6.
4. Fourth content type has 'Multilingual settings' as 'Enabled, with field translation' i.e. Entity Translation.
Comments / Comment fields can be translated using Entity Translation.
D7 test result
D7 1. Drupal 7 content type has multilingual support 'disabled'
D7 2. Drupal 7 content type has multilingual support 'enabled'.
This means that the nodes can have a language code but the different nodes cannot be linked as translations of each other.
D7 3. Drupal 7 content type has multilingual support 'Enabled, with translation'.
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.
D7 4. Drupal 7 content type has multilingual support 'Enabled, with field translation' i.e. Entity Translation
Conclusion
Conclusion 1: Patch #18 covers D6 only. I propose that we limit the scope of this issue to D6 only and create a follow-up for D7.
Conculsion 2:
The mapping from 2 to true is incorrect. It should be false. This is because the comments in D6 are independent from each other i.e. it is not possible to translate comments from one language to another.
Conclusion 3: D7 Entity Translation option is correctly covered. This was done in #2073467: Migrate Drupal 7 Entity Translation settings to Drupal 8.
Conclusion 4: D7 multilingual options 'Enabled' and 'Enabled, with translation' are not covered.
Comment #21
masipila CreditAttribution: masipila as a volunteer commentedOh, and forgot to mention that I updated the issue summary to be more explicit on the different scenarios. It can also be used for ensuring that we have all scenarios covered in the automated tests.
Comment #22
quietone CreditAttribution: quietone as a volunteer commented@masipila, Thanks! I see you've setup your own d6 an d7 version for testing. Would it be possible for you to add those cases to the d6 and d7 fixtures, if they are not already there?
Comment #23
masipila CreditAttribution: masipila as a volunteer commentedI checked the multilingual settings of the content types in the D6 fixture:
1. Content type with Multilingual support 'Disabled': Most of the content types are like this so there is plenty to choose from.
2. Content type with Multilingual support 'Enabled': There are currently no content types configured like this.
3. Content type with Multilingual support 'Enabled, with translation': Article.
For 2, I propose that we use content type 'Migrate test story'. It does not have any content in the fixture at the moment so changing the multilingual mode of this content type would hopefully not break too many tests (if any).
I also checked the multilingual settings of the content types in the D7 fixture. I'm quite confused because Article content type has nodes which clearly have a defined language but yet the multilingual mode is 'Disabled'.
I propose that we configure the D7 fixture content types as follows:
1. Content type with Multilingual support 'Disabled': page.
2. Content type with Multilingual support 'Enabled': There are currently no content types configured like this. I propose we use blog for this.
3. Content type with Multilingual support 'Enabled, with translation': There are currently no content types configured like this. I propose we use Article for this.
4. Content type with Multilingual support 'Enabled, with field translation': There are currently no content types configured like this.. I propose we use test_content_type for this.
I need to check out from the hotel in less than an hour from now so unfortunately I can't post a patch with these proposed changes right now.
Cheers,
Markus
Comment #24
quietone CreditAttribution: quietone as a volunteer commentedThis patch is only the change to d6_dump suggested in 23 above (changing Migrate test story) content type. I want to see what, if any, tests fail.
Comment #26
quietone CreditAttribution: quietone as a volunteer commentedSince that failure is on a test of an absent body field, let's try another content type, this time, Sponsor.
Making the changes to the D7 database via the UI are proving impossible. More details on that later.
Comment #28
quietone CreditAttribution: quietone as a volunteer commentedThat is better. Now add back in the patch from #18 plus a fix for the MigrateUpgrade6Test
Comment #30
quietone CreditAttribution: quietone as a volunteer commentedThis changes the content type, Sponsor, to have a multilingual setting of 'Enabled' and updates the test.
Comment #32
quietone CreditAttribution: quietone as a volunteer commentedI can't get the MigrateUpgrade test to run locally today. Here is an update for the entity count.
Comment #34
quietone CreditAttribution: quietone as a volunteer commentedAlso need to update the count in the Incremental as well.
Comment #36
masipila CreditAttribution: masipila as a volunteer commentedThanks @quietone for working on this!
I think this needs to be re-rolled now that #3016011: Reroll all migrate dump files landed...
I've been super-duper busy lately again but I'll try to find time to test the i18n patches.
Question: How do you feel now about the scope of this issue? Should we do D7 in the same issue or open a follow-up on that? I would be leaning towards opening a follow-up so that we would minimize the risk for a need to re-roll fixtures...
Cheers,
Markus
Comment #37
heddnTriaging the issue queue.
Comment #38
quietone CreditAttribution: quietone as a volunteer commentedHere is the reroll.
Re the question in #36 about making a follow up for D7. The answer is that I am still on the fence about that. I want to have another look at what is required for D7 and I won't be able to do that for about two days.
Settings NR for the testbot.
Comment #39
quietone CreditAttribution: quietone as a volunteer commentedDid some more testing and had to make some changes to the migration so the result matches what is in the IS. Updated the IS to identify the Drupal 6 content types associated with each language content settings to help testers.
Comment #41
quietone CreditAttribution: quietone as a volunteer commentedSilly, forgot to update the test.
Comment #42
quietone CreditAttribution: quietone as a volunteer commentedSettings to NW to decide about adding the D7 migration here or to do that in a new issue.
Comment #43
quietone CreditAttribution: quietone as a volunteer commentedThis is to test what breaks when changing the Drupal 7 basic page from multilingual Disabled to Enable. I tried to do this with the UI but kept getting an error message "An illegal choice has been detected" so I changed the variable directly. Not sure what problems that may cause.
Comment #46
quietone CreditAttribution: quietone as a volunteer commentedNot bad, only 4 errors and after a look it appears they can be corrected and not lose any tests. So, I went ahead and added a migration and test for Drupal7. The test passes but I have not tested it from the UI to be sure nor have I fixed the errors reported in #43.
Comment #48
quietone CreditAttribution: quietone as a volunteer commentedGood, the same tests fail and no new failures. This does look like it will work.
Comment #49
quietone CreditAttribution: quietone as a volunteer commentedReview again and need to revert changes to Drupal 6 version as I misread the IS. First, lets run the tests on this updated version and then attend to the errors.
Comment #51
quietone CreditAttribution: quietone as a volunteer commentedNow, work on fixes the failures. This has fixes for two tests plus removes unnecessary changes from the fixture which may also fix the others.
This still needs a migration for this case:
4. If the Drupal 7 content type has multilingual support as 'Enabled, with field translation'.
Drupal 7 fixture: test_content_type.
Comment #52
quietone CreditAttribution: quietone as a volunteer commentedAh a new day and I see I got the number wrong on the patch. Uploading the same patch with correct number of this comment (52) to avoid confusion.
Comment #53
quietone CreditAttribution: quietone as a volunteer commentedNow add in the final migration,
4. If the Drupal 7 content type has multilingual support as 'Enabled, with field translation'.
Drupal 7 fixture: test_content_type.
Assuming this passes tests, it will be ready for review. I do wonder if the new process plugin, content_translation_enabled_setting, show be more generic and handle the other entity type that are translatable with entity translation.
Comment #54
quietone CreditAttribution: quietone as a volunteer commentedDecided to change the new process plugin to be more flexible. This moves the static map from the migration into the process plugin, but I think I like this better.
Comment #55
quietone CreditAttribution: quietone as a volunteer commentedThis is ready for review
Comment #56
masipila CreditAttribution: masipila as a volunteer commentedAssigning to self for review
Comment #57
masipila CreditAttribution: masipila as a volunteer commentedHi,
I re-tested patch #54 manually, same tests as in #20. Unfortunately I need to kick this back.
Drupal 6
1. D6 Content type with multilingual settings 'disabled': All tests OK
2. D6 Content type with multilingual settings 'enabled': All tests OK
3. D6 Content type with multilingual settings 'enabled, with translations' (Article in D6 fixture): TEST FAILED, details below.
Details for 3:
Drupal 7
4. D7 Content type has multilingual support 'disabled'. All tests OK.
5. D7 Content type has multilingual support 'enabled'. All tests are now OK.
6. D7 content type has multilingual support 'Enabled, with translation'. TEST FAILED. Details below.
7. D7 content type has multilingual support 'Enabled, with field translation'. TEST FAILED. Details below.
Details for 6:
Details for 7:
Issue 7A: D8 'Default Language' is 'Not specified'. Should be 'Interface text language selected for page' as described in the issue summary.
Issue 7B: D8 'Enable translation' does not respect the D7 Entity Translation settings.
8. D7 fixture / content type settings
According to #49, the content type language settings were supposed to be modified in the D7 fixture. As @quietone mentioned, there is something strange going on with our fixture (she modified the values directly to the variables because UI didn't allow her to change it). All D7 fixture content types still have their language settings as 'Disabled' at least when you look at them from the D7 UI...
Cheers,
Markus
Comment #58
quietone CreditAttribution: quietone as a volunteer commentedNeeds reroll
Comment #59
quietone CreditAttribution: quietone as a volunteer commentedPhew, that didn't involve editing a fixture, just MigrateUpgrade6Test.php.
Comment #60
quietone CreditAttribution: quietone as a volunteer commentedMaking a few things bold in the IS to make it a bit easier to find.
Comment #62
quietone CreditAttribution: quietone as a volunteer commentedRight, couple of things.
1) I am not getting the failures that masipila reports. I was working in D7 and using the fixture all was well. I went to add a new content type to the fixture and get this error in the UI 'An illegal choice has been detected. Please contact the site administrator.'. The D7 fixture is just too wonky to work with. That needs to be fixed before any more work on D7 migrations and that needs an issue.
2) This issue will be split into a D6 and D7 version because of 1)
3) This patch removes the D7 code and fixes the test, unless I messed things up.
Comment #63
quietone CreditAttribution: quietone as a volunteer commentedSo the work remaining here, from #57, is to fix this
3. D6 Content type with multilingual settings 'enabled, with translations' (Article in D6 fixture): TEST FAILED, details below.
Details for 3:
When the D6 content type setting is 'enabled, with translations', the D8 content type setting 'Enable translation' should be false.
This is because the D6 comments are **not** conceptually translations of each other.
Updated the IS to remove references to Drupal 7
Comment #64
quietone CreditAttribution: quietone as a volunteer commentedI'm unable to reproduce the error results reported in #57 for 'enabled, with translation'
After the migration both article and employee have the following configuration showing the content_translation is indeed false.
I made another content type and set it to 'enabled, with translation' and got the same results.
@masipila, where you using your own test db? Can you provide more details? How can I reproduce the error?
Comment #65
quietone CreditAttribution: quietone as a volunteer commentedThis needs testing from someone else to confirm, or not, the failure reported by masipila.
Comment #66
heddnLet's tag for manual testing since we can't seem to reproduce what Markus found.
Comment #67
masipila CreditAttribution: masipila as a volunteer commentedPatch doesn't apply anymore, needs re-roll
Comment #68
quietone CreditAttribution: quietone as a volunteer commentedOK, rerolled.
Comment #70
masipila CreditAttribution: masipila as a volunteer commentedI re-tested patch 68.
Test report from Drupal 6 tests:
The D7 was split to a separate issue from this so no need to test that under this issue.
The previous automated test failed due to a mismatch 92/93. Once you fix that, please also fix this nit from the method description:
Should be 'Tests migration of comment language settings.'
Otherwise the patch looks ready to me once the offset by one (92 / 93) is fixed.
Cheers,
Markus
Comment #71
quietone CreditAttribution: quietone as a volunteer commentedWoohoo! Thanks Markus!
Fixes for the two items in #70.
Comment #72
masipila CreditAttribution: masipila as a volunteer commentedThanks Vicki!
I have manually tested this, see test report in #70.
I have reviewed the patch and the feedback has been addressed.
The issue summary now describes the scope of this issue (I added the link to the D7 follow-up to the IS).
MySQL and PostgreSQL tests are green. Once the SQLite tests that are currently running are green, this is RTBC.
Markus
Comment #73
quietone CreditAttribution: quietone as a volunteer commentedAnd thanks to you too Markus!
In #72 Markus said this can be RTBC when all tests are passing, they are so I will set it to RTBC.
Comment #74
Gábor HojtsyHm, how is this limited to only multilingual sites? Eg. it attempts to set a content translation 3rd party setting but is apparently not making content translations a requirement?
Also should it have the Multilingual tag on it?
Comment #75
Gábor HojtsyI looked a bit further and the only language related plugin used, d6_language_content_settings seems to be dependent on locale only. How does this depend on content translation needing to be on the target system?
Comment #76
quietone CreditAttribution: quietone as a volunteer commented@Gábor Hojtsy, nice question. I done a little digging and this is what I have found so far.
Content Translation has a listener for the MigrateImportEvent which updates the field storage definitions for the entity type specified in the migrate destination configuration (using property content_translation_update_definitions). This was introduced in #2225775: Migrate Drupal 6 core node translation to Drupal 8 the same patch that brought in d6_language_content_settings.yml. Obviously, if content translation is not enabled the updates will not happen.
I wanted to see what happens when content_translation is not enabled so I commented content_translation out of MigrateLanguageContentCommentSettingsTest and ran it. That results in results in schema errors.
Perhaps this is what vasi is referring to in Issue #2225775- Comment #198 because the next patch in #199 is the first one with the listener. If that is true, there is a dependency on content translation. And even though the source plugin has a source_module of 'locale', it uses i18n variables as well. All indicators that the existing family of '_language_content_settings' migrations are Multilingual and should be moved to content_translations/migrations.
It is now I wish I had more experience with D6/D7 sites. Does this make sense?
TODO:
Another thing to do is to document the destination property, content_translation_update_definitions.
Comment #77
Gábor HojtsyThere is definitely a dependency on content translation if we need to set third party settings for content translation :) That would not be valid in configuration unless content translation module is present. Default langcode and language alterable would be settable / migrateable without content translation, but I don't know if there is a way to make the final part only conditional on content translation.
Comment #78
quietone CreditAttribution: quietone as a volunteer commentedMy first reaction is that no, there isn't a way and that two migrations are needed. Ideally, one that does the parts not requiring content translation and one that does that part requiring content translation. This requires more thought than I can give right now.
Comment #79
masipila CreditAttribution: masipila as a volunteer commentedHmm, why don't we just move this to content_translations?
Comment #80
Gábor HojtsyBased on the source essentially requiring content translation features for these to be there, even though D8 is more flexible and allow part of the features to be present without content translation, this could indeed just expect content translation IMHO. I don't expect that being a problem. IMHO splitting this would be more like hair splitting.
Comment #81
masipila CreditAttribution: masipila as a volunteer commentedMy point exactly. These multilang migrations are complex enough without artificially splitting these into two.
Comment #82
heddnWhat if we move the migration? The only implication is we'd need to add a hook update to language.module that if migrate_drupal_multilingual is enabled, then enable content_translation module.
We wouldn't be able to easily change the name of the migration.yml, because the name is part of the API and that would be bad. But we can move it. We cannot rename it because the mapping tables and migrate_drupal_ui has the old names already saved. But we can safely move it.
Comment #84
quietone CreditAttribution: quietone as a volunteer commentedMoving the new migration to content_translation.
Do we really need to add a hook_update for a new migration?
Comment #85
heddnNo need for an update if this is a new migration. Ignore that part.
I was about to mark this RTBCed since all other feedback is now addressed. But then I noticed this comment in the yml and said, what does this mean? It don't seem to relate to target_bundle. What is it all about? Can we clarify this comment?
Comment #86
quietone CreditAttribution: quietone as a volunteer commentedYes, that is cryptic. It is from d6_language_content_settings.yml which this one started from and it applies to the whole migration. And worse I added it #2225271: Migrate content type language settings from Drupal 6 & 7 Comment #26 and now think it is unhelpful. Not only is there the confusion you experienced, thinking it had to do with the property it is directly above but it doesn't really give any useful information. Comments in the migrations tend to focus on the variables that are used in a migration, not the ones that are ignored.
It is a difficult call to remove a comment but in this case it should go. If we wish to comment about the i18 variables that are ignored then that should be it's own issue and it should cover all the relevant migrations. Also these variables are not retrieved by the source plugin so maybe not worth the effort. Unless, that is, we want to modify all the relevant source plugins to get more variables even though they are not used in core.
This patch removes the comment.
Comment #87
heddnWe be good now.
Comment #89
heddnI think a random failure.
Comment #92
Gábor HojtsyThanks for resolving my concerns! Woot! Committed.