Problem/Motivation
Menu links in Drupal 7 are translated using i18n_menu submodule of the suite i18n, we need to migrate those respecting the language settings. This should be similar to the D6 version, #2225587: Migrate D6 i18n menu links
The D6 patch included a migration for language content menu settings as well. For D7 that was done in a separate issue, #3110669: Migrate d7 menu language content settings.
Proposed resolution
Ensure that the menu_links migration sets a default value for the langcode. From #3013625: Menu language not properly migrated from D7 localized menu links..
Add two migrations one for localized menu links, d7_menu_links_localized, and another one for translations that are not localized, d7_menu_links_translation.
This migration should also set the state of the menu_links migration to finished.
Remaining tasks
Write a patch
Review
Commit
| Comment | File | Size | Author |
|---|---|---|---|
| #109 | 3008028.spelling.patch | 883 bytes | alexpott |
| #105 | 3008028-105.patch | 47.21 KB | quietone |
| #105 | diff-101-105.txt | 1 KB | quietone |
| #101 | 3008028-101.patch | 47.2 KB | quietone |
| #101 | interdiff-99-101.txt | 1.45 KB | quietone |
Comments
Comment #2
quietone commentedThis is mostly a copy of the d6 versions of the migrations for the menu links. For d7 there are some new fields in the tables and the i18n tables names are different. The other difference is that in D7 I was able to translate the menu title and description which I wasn't able to do in Drupal 6. That brings the total translation related migrations here to 3; d7_language_content_menu_settings, d7_menu_links_translation and d7_menu_translation. Perhaps this can be broken up into 3 patches. (I was keen on finishing the lot and didn't consider that as I went along).
This d7_menu_links_translation needs the changes to the i18QueryTrait that are in #3001749: Migrate D7 i18n custom blocks so that one is postponded but the other two can proceed, if split off.
TODO:
Menu Link Translation was done with the translation mode of 'translate and localize'. Investigation is needed to find out how to migrate that setting.
Not running the tests but marking as NW for considering breaking this into smaller patches.
Comment #3
quietone commentedThe language_menu_content_settings migration can be split out but it will be much easier when the source fixture changes in #2970848: i18n Variable to config: site offline message [d7] are committed.
Therefore, postponing.
Comment #4
quietone commentedThis is no longer postponed but will need a reroll because of the fixture changes and maybe for breaking into small migrations. The more I think about the more I dislike breaking this up because it just means more rerolls as the fixture changes.
Comment #5
bserem commentedComment #6
bserem commentedAttached patch applies on D8.6.3 that has all the code changes required.
Still doesn't apply the language to the imported menus though, all links come out with the site default language.
Comment #7
bserem commentedComment #8
bserem commentedComment #9
quietone commented@bserem, thanks for the reroll.
Adding a test.
Comment #10
bserem commented@quietone I still haven't managed to get the patch to migrate the languages too :|
Comment #11
bserem commentedAttached patch applies against 8.6.x
There is no interdiff from #6 because there are only line offset and no code changes.
Comment #12
quietone commentedThanks for the rerolls. I added the test before I realized the reroll was for 8.6.
Let's see if this reroll works for 8.7.x
Comment #14
bserem commentedIn any case, we couldn't get localized menus to migrate with the patch from this issue.
All our work is documented here: #3013625: Menu language not properly migrated from D7 localized menu links. where we made a patch that migrates localized menus.
Comment #15
quietone commentedSeems to me this should be migrate critical like the other i18n issues.
Comment #16
quietone commentedNeeded a reroll. Interdiff fails so no interdiff.
Comment #18
quietone commentedPossible fixes for the tests
Comment #20
quietone commentedFix namespace and comment on failing test.
Comment #22
quietone commentedOnly fixed the namespace on one test and forgot the other
Comment #23
quietone commentedGood, back to passing tests. Setting to NW to address #14
Comment #24
phenaproximaAs per #2208401-96: [META] Remaining multilingual migration paths, I reviewed this patch for BC breaks. As it turns out, it only adds new plugin implementations and migrations, and doesn't change any APIs at all.
So, rest easy, release and framework managers: there are no BC breaks or implications in this patch.
Comment #26
quietone commentedThis fixture was used as the starting point in #2979966: Migrate D7 i18n taxonomy term language which went to RTBC, which is great. But this issue needs to get in first. Marking as a blocker for the remaining i18n d7 issues.
The next task here is to reduce the size of the fixture (my least favorite part of the process).
Comment #27
quietone commentedComment #28
quietone commentedComment #29
quietone commentedComment #30
quietone commentedWorking on a reroll. All the changes are to the fixture and an interdiff would be just noise. Since this one was already started it wasn't included in the recent #3022137: Update migrate fixtures for remaining active issues and perhaps that was an error. Anyway, this brings in the menu changes and increases the size of the fixture. Before trimming that I want to make sure all the tests pass.
Comment #31
quietone commentedNext steps is a review, comparing with Drupal6 version, and to see if the work referred to in #14 should move here.
Comment #32
quietone commentedAdded the patch and updated MigrateMenuLinkTest to use MigrateDumpAlter to remove the language column from menu_links which is added by i18n menu.
The interdiff fails.
Comment #33
gábor hojtsyNot postponed anymore.
Comment #34
gábor hojtsySome code in the fields list looks odd, like these:
Some docs are copy paste:
Also 90%+ of the patch is DB dump changes. Do we need them? A bunch of new translatable strings, i18n's tests listed, entity_translation's tests, etc. Especially after #3022137: Update migrate fixtures for remaining active issues landed.
Comment #35
quietone commentedFirst a reroll.
Comment #36
quietone commentedNow address the points from 34, except about the fixture. That will be next.
The fields list. The values here are copied from the existing source Menu source plugin in the system module. The ones used here are changed. Also changed the doc for the test.
Comment #39
quietone commentedThis patch contains fixes for the failing tests and the fixture was made by starting over from HEAD, and then trimmed a bit. Maybe more can be trimmed but lets check for test failures first. Fixture changes are required here because #3022137: Update migrate fixtures for remaining active issues was for the remaining active issues and excluded this one which was already in progress. Don't know why I thought that was a good decision all those months ago but it is what it is.
Comment #42
quietone commentedJust a reroll
Comment #44
quietone commentedI've decided to split this into smaller patches, just so each part is clear and smaller. A child issue for the language content menu settings, has been added #3110669: Migrate d7 menu language content settings.
Comment #45
quietone commentedAnd now an issue for the menu translation #3112249: Migrate d7 menu translation.
Comment #46
gábor hojtsyComment #47
quietone commentedUploading a work in progress so it doesn't get lost. This is ready to run tests.
And and the IS needs an update.
Comment #48
quietone commentedThis patch has two migrations for menu link translations, d7_menu_link_translation is for translations that are in the i18n_string and locales_target table and d7_menu_link_localized for translations that do not use those tables.
This is still a work in progress. Not sure yet if this should be split into two issues.
Comment #50
quietone commentedFix the coding standard errors. And correct the MigrateMenuLinkLocalizedTest.php so it tests the correct uri.
Comment #52
quietone commentedWorking on fixing the tests.
Comment #53
quietone commentedComment #55
quietone commentedRework this to remove the new source plugin and cleanup.
Comment #57
quietone commentedMore clean up.
Comment #58
quietone commentedComment #62
quietone commentedAdding credit from #3013625: Menu language not properly migrated from D7 localized menu links. which I'm closing as a duplicate since that issue is being solved here.
Comment #63
quietone commentedThis is now passing tests and ready for review, which pleases me, but it is actually postponed on #3112249: Migrate d7 menu translation.
Comment #65
firewaller commentedIs there an opportunity for an 8.9 version similar to 3112249?
Comment #66
quietone commented@firewaller, speaking for myself, I have a full schedule until next week. If you are Slack you could ask in #migration if someone is able to reroll it.
Comment #67
firewaller commentedAttached is a backported 8.9.2 version.
Comment #68
quietone commented@firewaller, thanks. Can you upload a diff please?
Started a test.
Comment #69
firewaller commented@quietone Sure thing.
FYI my patch is pretty barebones and excludes both the tests and 3112249 work. I will try to upload something more useable once I test it further.
Also, I didn't mean to remove the "Needs reroll" tag (maybe it was automatic?).
Comment #70
quietone commentedRerolling to 9.1.x.
Comment #71
quietone commentedComment #73
quietone commentedFix coding standards, remove debug line left in and make fixes to the fixture.
Comment #75
quietone commentedAh, missed another change to the fixture, the FixedLang menu.
Comment #77
quietone commentedYes, new adding a menu effects the entity count in Upgrade7Test and the ReviewForm test.
Comment #78
quietone commentedBack to postponed
Comment #79
quietone commentedThis will need a reroll when #3112249: Migrate d7 menu translation is committed.
The following needs to change as well.
s/public/protected/
Comment #80
quietone commentedRerolling because #3112249: Migrate d7 menu translation was committed. This included the patch from that issue, so the changes are larger removing that and making the changes in #79.
Comment #81
quietone commentedSome minor improvements.
Comment #82
daffie commentedFirst quick review. Will do a second one.
Can we only select the field "mlid" instead of all fields. Can we then call the method fetchField() without any parameters.
Can we change this to using a single if-statement?
Why set the default language to "en" instead of "und"?
Can we rewrite this query to:
Same as with MenuLink.
As far as I can see we now have 3 times exactly the same method. Can we put the method in a trait or any other solution which result in having a single definition of the method.
Why is the description value being removed?
I am missing the value
$expected[5]. Can you explain why? Maybe adding adding a comment to the patch with the explanation.Should it not be
'language' => 'und'?Comment #83
naresh_bavaskarComment #84
naresh_bavaskarI have tried to cover some of points from #82 comment, please review
Comment #85
quietone commented@naresh_bavaskar, to help reviewers and others working on this issue, please clarify which points from #82 have been addressed in #84.
Comment #86
naresh_bavaskar@quitetone yeah, i have addressed point 1 to 5..
6 to 9 is pending.
I forgot to mention addressed points numbers.
Comment #87
daffie commentedSecond review:
Please put the part
->fields('i18n')on a separate line.The query is a single table query. The part "i18n." can be removed from each line.
Why has the "description" this value? Other yml files don not have such a value.
Why is this code added? All fields from the menu_links are already added to the query result.
The order by for 'ml.mlid' is already added in the paretn query.
Can we change this to a single if-statement. If not, then explain why not.
Why is this constant added. It is not being used!
Why is this constant added. It is not being used!
Comment #88
quietone commentedfor #87
1. Fixed
2. Fixed
3. TODO
4. Removed. It is habit from similar issues.
5. Removed the orderBy
6. Fixed although I am not sure about the coding standards for this.
7. Removed
8. It was a reminder to use I18nQueryTrait, which obviously was forgotten. The trait, which uses the mentioned constant is now used.
Comment #90
quietone commented#82.
6. Made a trait.
7. Description is not a field in the D7 menu_links table. I noticed this when adding a new entry to the source test data.
8. Comment added.
9. Fixed.
And fixed the failing test.
Comment #91
quietone commentedAnd now for #87.3. Yes, it should be
description: description. description is put on the row by the parent prepareRow method.I think that covers all the points from the reviews in #82 and #87
Comment #92
daffie commentedWe can improve a little bit more by:
The I18nQueryTrait does not use the constant I18N_STRING_TABLE.
Comment #93
daffie commentedHere we can also make it a little more better:
Comment #94
ravi.shankar commentedComment #95
ravi.shankar commentedHere I have addressed comments #92.1, #92.3 and #93
Comment #96
daffie commented@ravi.shankar: Thank you for the updated patch!
Only the comment #92.2 is still open.
Comment #97
quietone commentedAddressing 92.2. Reworked MenuLinkTranslation to use the constant and I18nQueryTrait. The query method also change to make it more like the d6 version (I always find it helpful to have them similar), prepareRow changed to call the parent:prepareRow and remove the check that the row is already migrated since it is done in getPropertyNotInRowTranslation.
Comment #99
quietone commentedSeems that a reroll is needed as well. It is the fixture that needs a small change, so that the yahoo menu link is in a translation set.
Comment #100
daffie commentedIn the trait
core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkTranslation.phpwe have the variable$i18nStringTable. Why do we then create a new constant calledI18N_STRING_TABLE? Can we not use the variable from the trait and remove the constantI18N_STRING_TABLE. If you do not like to do that, because in other migration code it is done the same way, then please say so. If @quietone does not want to change the constant as described above, then the it is RTBC for me.Comment #101
quietone commentedI'm fairly certain the use of the constant started in #3001749: Migrate D7 i18n custom blocks with the d6 and d7 block translation source plugins. As I recall it was expected that the future translation migrations would be able to use the same pattern. That hasn't worked out though. So I have made the requested change.
Comment #102
daffie commentedIt is for me now RTBC.
Comment #104
daffie commentedBack to RTBC.
Comment #105
quietone commentedI do wish the status would change when a patch no longer applies.
Needed a reroll.
Comment #106
daffie commentedAs far as I can see this is a straight reroll. Back to RTBC.
Comment #108
gábor hojtsyLooks great, thanks! I am moving this to backport, but I would not hold my breath on that honestly. While there is potentially 2 more bugfix releases left of 9.0 that this could get into, #3110669: Migrate d7 menu language content settings needs to land in 9.0 first and then #3112249: Migrate d7 menu translation for this to land.
Comment #109
alexpottThis introduced a spelling mistake into core - we automate spellchecking. Here's a patch to fix this.
Comment #111
quietone commentedAdding clarification for the remaining i18n migrations. There are three of these issues that could be backported and they need to be done in this order. One reason is because of the fixture changes.
Comment #112
jonathan1055 commentedThis commit https://git.drupalcode.org/project/drupal/commit/ce767b8 in #107 above has caused the new coding standards message
It first appeared 15 Oct 2020 at 04:07 BST see https://www.drupal.org/pift-ci-job/1851506
This is such a minor fix, can this be done here? or does it need a separate issue?
Comment #113
jonathan1055 commentedI have raised #3178338: Fix coding standard fail committed to core 9.1 and 9.2 to fix the coding standard fault reported above.
Comment #114
wim leers9.1.0 was released nine days ago. I don't think backporting is still relevant?
Comment #116
benjifisherWe decided it is too late to backport #3110669: Migrate d7 menu language content settings, so we will not backport this issue either. Fixed for 9.1.x.
Comment #117
benjifisher