tl;dr:
On localized menu links from a D7 source, the language is not migrated and the default menu language is assigned to all links.
Description:
I added the configuration for migration from a D7 site using migrate-upgrade and drush8:
drush migrate-upgrade --legacy-db-url=mysql://db:db@localhost/db7 --legacy-root=http://localhost:8087 --configure-only
I executed only the menu and menu links migrations (they do not have other dependencies, as long as the menus have absolute paths)
drush ms | grep menu
Import from Drupal 7 (migrate_drupal_7) upgrade_menu_settings Idle 0 0 0
Import from Drupal 7 (migrate_drupal_7) upgrade_d7_menu Idle 12 12 0 2018-11-14 14:54:18
Import from Drupal 7 (migrate_drupal_7) upgrade_d7_menu_links Idle 298 298 0 2018-11-14 14:54:50
Import from Drupal 7 (migrate_drupal_7) upgrade_node_translation_menu_links Idle 298 0 298
drush migrate:import upgrade_d7_menu
drush migrate:import upgrade_d7_menu_links
Now I have the menus in my new D8 site, and I also have the links. All of the links however point to the default language.
D7 db entries:
MariaDB [db7]> select language, link_title from menu_links where menu_name like "menu-main%" order by link_title limit 15;
+----------+--------------+
| language | link_title |
+----------+--------------+
| fr | Jeunesse |
| fr | 2017 Thoune |
| de | 2017 Thun |
| it | 2017 Thun |
| fr | 2018 Zoug |
| de | 2018 Zug |
| it | 2018 Zugo |
| it | 2019 Chillon |
| de | 2019 Chillon |
| fr | 2019 Chillon |
| it | 360° |
| fr | 360° |
| de | 360° |
| fr | A paraître |
| de | Aargau |
+----------+--------------+
15 rows in set (0.00 sec)
D8 db entries:
MariaDB [db8]> select langcode, title from menu_link_content_data where menu_name like "menu-main-navigation" order by title limit 15;
+----------+--------------+
| langcode | title |
+----------+--------------+
| de | Jeunesse |
| de | 2017 Thoune |
| de | 2017 Thun |
| de | 2017 Thun |
| de | 2018 Zoug |
| de | 2018 Zug |
| de | 2018 Zugo |
| de | 2019 Chillon |
| de | 2019 Chillon |
| de | 2019 Chillon |
| de | 360° |
| de | 360° |
| de | 360° |
| de | A paraître |
| de | Aargau |
+----------+--------------+
15 rows in set (0.01 sec)
One would expect that the language should be migrated too.
It is possible to change the language from the DrupalUI afterwards, so Drupal 8 is configured correctly to handle multilingual menus.
I mark this as major, since it makes the migration not usable from/to multilingual sites. Please feel free to change.
Comments
Comment #2
bserem commentedComment #3
bserem commentedComment #4
zekvyrin commentedComment #5
bserem commentedComment #6
zekvyrin commentedComment #7
zekvyrin commentedNoticed that all the menu links after migrate had the same language, which isn't true for our case.
The original language was replaced by the default language of the menu.
With this patch the migrated menu links have the same language like the original menu links in d7.
Comment #8
bserem commentedI added the patch on a 8.6.3 installation and executed the migration again.
This time the menu in Drupal 8 has been imported along with the proper languages, something that I can verify inside the sql tables:
Comment #9
zekvyrin commentedComment #10
catchThis could do with a test addition.
Comment #11
bserem commentedWe had a discussion with @stefanospetrakis in Mountaincamp Davos where he informed us about the existence of fixtures. We'll try to revive this thread and come up with an updated patch, hopefully with his help.
Comment #12
stefanos.petrakistrue words, already had a go at it on my local dev, would like to post some tests here that cover this case as soon as I have something presentable to share.
Comment #13
bserem commentedComment #14
stefanos.petrakisHere are some tests that try to capture this scenario.
First patch (tests only) should fail.
Full patch (tests and #4) should pass.
Comment #15
stefanos.petrakisUpdated tests for 8.8.x
Comment #17
quietone commentedThanks for the patch.
What caused the additional column, language, to the menu_custom table?
Comment #18
stefanos.petrakisHi
We need to add language information to the source fixtures data, which is saved in the language column.
Comment #19
quietone commented@stefanos.petrakis, What module adds the language column? i18n_menu?
Comment #20
stefanos.petrakis@quietone: Good question, one for @bserem I believe to answer.
Comment #22
quietone commentedIt is i18n_menu, from i18n_menu.install
Comment #23
quietone commentedWe also need to make sure that the d6 test fixture functions in a D6 site. Ideally, one would bring up a D6 site with the test fixture, enable i18nmenu and make alterations via the UI for the menu language. I presume a menu will need to have 'localize' selected and some translations added. Once that is done, use db-tools to dump that database to drupal6.php. See Generating database fixtures for D8 Migrate tests.
Comment #24
quietone commentedNeeds work for the points in #23
Comment #25
quietone commentedAdd tag and parent.
Comment #26
quietone commentedThe work here is now included in #3008028: Migrate D7 i18n menu links so closing this as a duplicate and added credit over there.