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

CommentFileSizeAuthor
#109 3008028.spelling.patch883 bytesalexpott
#105 3008028-105.patch47.21 KBquietone
#105 diff-101-105.txt1 KBquietone
#101 3008028-101.patch47.2 KBquietone
#101 interdiff-99-101.txt1.45 KBquietone
#99 3008028-99.patch47.31 KBquietone
#99 interdiff-97-99.txt698 bytesquietone
#97 3008028-97.patch47.31 KBquietone
#97 interdiff-95-97.txt2.75 KBquietone
#95 interdiff_91-95.txt5.2 KBravi.shankar
#95 3008028-95.patch47.33 KBravi.shankar
#91 3008028-91.patch47.5 KBquietone
#91 interdiff-90-91.txt507 bytesquietone
#90 3008028-90.patch47.51 KBquietone
#90 interdiff-88-90.txt14.1 KBquietone
#88 3008028-88.patch47.59 KBquietone
#88 interdiff-84-88.txt6.58 KBquietone
#84 interdiff-81-84.txt3.78 KBnaresh_bavaskar
#84 3008028-84.patch48.68 KBnaresh_bavaskar
#81 3008028-81.patch48.72 KBquietone
#81 interdiff-80-81.txt2.25 KBquietone
#80 3008028-80.patch48.92 KBquietone
#80 diff-77-80.txt19.67 KBquietone
#77 3008028-77.patch64.19 KBquietone
#77 interdiff-75-77.txt1.16 KBquietone
#75 3008028-75.patch63.11 KBquietone
#75 interdiff-73-75.txt507 bytesquietone
#73 3008028-73.patch62.8 KBquietone
#73 interdiff-70-73.txt4.97 KBquietone
#70 3008028-70.patch62.04 KBquietone
#70 diff-57-70.txt7.75 KBquietone
#69 interdiff_57-66.txt46.37 KBfirewaller
#67 3008028-8.9.2-66.patch15.13 KBfirewaller
#57 3008028-57.patch63.58 KBquietone
#57 interdiff-55-57.txt21.77 KBquietone
#55 3008028-55.patch58.37 KBquietone
#55 interdiff-52-55.txt11.64 KBquietone
#52 3008028-52.patch57.4 KBquietone
#52 interdiff-50-52.txt4.84 KBquietone
#50 3008028-50.patch56.34 KBquietone
#50 interdiff-48.50.txt2.91 KBquietone
#48 interdiff-47-48.txt13.12 KBquietone
#48 3008028-48.patch56.38 KBquietone
#47 3008028-47.patch53.42 KBquietone
#42 3008028-42.patch661.09 KBquietone
#39 3008028-39.patch383.63 KBquietone
#39 interdiff-36-39-exclude-fixture.txt2.66 KBquietone
#36 3008028-36.patch729.05 KBquietone
#36 interdiff-35-38.txt2.78 KBquietone
#35 3008028-35.patch729.1 KBquietone
#32 3008028-32.patch729.11 KBquietone
#32 interdiff-30-32.txt762 bytesquietone
#30 3008028-30.patch1.72 MBquietone
#22 interdiff-20-22.txt646 bytesquietone
#22 3008028-22.patch127.81 KBquietone
#20 interdiff-18-20.txt909 bytesquietone
#20 3008028-20.patch127.81 KBquietone
#18 interdiff-16-18.txt1.44 KBquietone
#18 3008028-18.patch127.81 KBquietone
#16 3008028-16.patch126.37 KBquietone
#12 3008028-12.patch130.34 KBquietone
#7 interdiff-6-2.txt1.59 KBbserem
#2 3008028-2-review-only.txt24.1 KBquietone
#11 3008028-11.patch138.34 KBbserem
#6 3008028-6.patch138.31 KBbserem
#2 3008028-2.patch139.44 KBquietone
#8 interdiff-2-6.txt1.49 KBbserem

Comments

quietone created an issue. See original summary.

quietone’s picture

Status: Active » Needs work
StatusFileSize
new139.44 KB
new24.1 KB

This 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.

quietone’s picture

Status: Needs work » Postponed

The 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.

quietone’s picture

Status: Postponed » Needs work

This 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.

bserem’s picture

bserem’s picture

StatusFileSize
new138.31 KB

Attached 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.

bserem’s picture

StatusFileSize
new1.59 KB
bserem’s picture

StatusFileSize
new1.49 KB
quietone’s picture

@bserem, thanks for the reroll.

Adding a test.

bserem’s picture

@quietone I still haven't managed to get the patch to migrate the languages too :|

bserem’s picture

StatusFileSize
new138.34 KB

Attached patch applies against 8.6.x
There is no interdiff from #6 because there are only line offset and no code changes.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new130.34 KB

Thanks 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

Status: Needs review » Needs work

The last submitted patch, 12: 3008028-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

bserem’s picture

In 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.

quietone’s picture

Issue tags: +Migrate critical

Seems to me this should be migrate critical like the other i18n issues.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new126.37 KB

Needed a reroll. Interdiff fails so no interdiff.

Status: Needs review » Needs work

The last submitted patch, 16: 3008028-16.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new127.81 KB
new1.44 KB

Possible fixes for the tests

Status: Needs review » Needs work

The last submitted patch, 18: 3008028-18.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new127.81 KB
new909 bytes

Fix namespace and comment on failing test.

Status: Needs review » Needs work

The last submitted patch, 20: 3008028-20.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new127.81 KB
new646 bytes

Only fixed the namespace on one test and forgot the other

quietone’s picture

Status: Needs review » Needs work

Good, back to passing tests. Setting to NW to address #14

phenaproxima’s picture

As 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.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Issue tags: +blocker

This 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).

quietone’s picture

Issue summary: View changes
Status: Needs work » Postponed
quietone’s picture

Status: Postponed » Active
Issue tags: +Needs reroll
quietone’s picture

Assigned: Unassigned » quietone
Status: Active » Needs work
quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.72 MB

Working 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.

quietone’s picture

Status: Needs review » Needs work
Issue tags: -blocker, -Needs reroll

Next steps is a review, comparing with Drupal6 version, and to see if the work referred to in #14 should move here.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new762 bytes
new729.11 KB

Added 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.

gábor hojtsy’s picture

Issue summary: View changes

Not postponed anymore.

gábor hojtsy’s picture

Status: Needs review » Needs work

Some code in the fields list looks odd, like these:

+      'menu_name' => $this->t('The menu name . Primary key'),
+      'title' => $this->t('The human - readable name of the menu'),

Some docs are copy paste:

+  /**
+   * Tests migration of system (site) variables to system.site.yml.
+   */
+  public function testMenuTranslation() {

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.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new729.1 KB

First a reroll.

quietone’s picture

StatusFileSize
new2.78 KB
new729.05 KB

Now 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.

The last submitted patch, 35: 3008028-35.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 36: 3008028-36.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.66 KB
new383.63 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 39: 3008028-39.patch, failed testing. View results

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new661.09 KB

Just a reroll

Status: Needs review » Needs work

The last submitted patch, 42: 3008028-42.patch, failed testing. View results

quietone’s picture

I'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.

quietone’s picture

And now an issue for the menu translation #3112249: Migrate d7 menu translation.

gábor hojtsy’s picture

Title: Migrate D7 i18n menu links » [META] Migrate D7 i18n menu links
quietone’s picture

Issue tags: +Needs issue summary update
StatusFileSize
new53.42 KB

Uploading a work in progress so it doesn't get lost. This is ready to run tests.

  • This patch includes #3112249: Migrate d7 menu translation.
  • The menu links migrations seem to be working fine using a custom local d7 source site.
  • The source plugin tests are working.
  • The Kernel migration tests need to be written.

And and the IS needs an update.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new56.38 KB
new13.12 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 48: 3008028-48.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.91 KB
new56.34 KB

Fix the coding standard errors. And correct the MigrateMenuLinkLocalizedTest.php so it tests the correct uri.

Status: Needs review » Needs work

The last submitted patch, 50: 3008028-50.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new4.84 KB
new57.4 KB

Working on fixing the tests.

quietone’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 52: 3008028-52.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new11.64 KB
new58.37 KB

Rework this to remove the new source plugin and cleanup.

Status: Needs review » Needs work

The last submitted patch, 55: 3008028-55.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new21.77 KB
new63.58 KB

More clean up.

quietone’s picture

Assigned: quietone » Unassigned

quietone credited Zekvyrin.

quietone credited catch.

quietone’s picture

Adding 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.

quietone’s picture

Issue summary: View changes
Status: Needs review » Postponed

This is now passing tests and ready for review, which pleases me, but it is actually postponed on #3112249: Migrate d7 menu translation.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

firewaller’s picture

Is there an opportunity for an 8.9 version similar to 3112249?

quietone’s picture

Issue tags: +Needs reroll

@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.

firewaller’s picture

Issue tags: -Needs reroll
StatusFileSize
new15.13 KB

Attached is a backported 8.9.2 version.

quietone’s picture

@firewaller, thanks. Can you upload a diff please?

Started a test.

firewaller’s picture

StatusFileSize
new46.37 KB

@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?).

quietone’s picture

Status: Postponed » Needs review
StatusFileSize
new7.75 KB
new62.04 KB

Rerolling to 9.1.x.

quietone’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 70: 3008028-70.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new4.97 KB
new62.8 KB

Fix coding standards, remove debug line left in and make fixes to the fixture.

Status: Needs review » Needs work

The last submitted patch, 73: 3008028-73.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new507 bytes
new63.11 KB

Ah, missed another change to the fixture, the FixedLang menu.

Status: Needs review » Needs work

The last submitted patch, 75: 3008028-75.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.16 KB
new64.19 KB

Yes, new adding a menu effects the entity count in Upgrade7Test and the ReviewForm test.

quietone’s picture

Status: Needs review » Postponed

Back to postponed

quietone’s picture

This will need a reroll when #3112249: Migrate d7 menu translation is committed.

The following needs to change as well.

+++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkLocalizedTest.php
@@ -0,0 +1,100 @@
+  public static $modules = [

+++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTranslationTest.php
@@ -0,0 +1,96 @@
+  public static $modules = [

+++ b/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/d7/MenuLinkLocalizedTest.php
@@ -0,0 +1,222 @@
+  public static $modules = ['menu_link_content', 'migrate_drupal'];

+++ b/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/d7/MenuLinkTranslationTest.php
@@ -0,0 +1,180 @@
+  public static $modules = ['menu_link_content', 'migrate_drupal'];

+++ b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTranslationTest.php
@@ -0,0 +1,67 @@
+  public static $modules = [

+++ b/core/modules/system/tests/src/Kernel/Plugin/migrate/source/d7/MenuTranslationTest.php
@@ -0,0 +1,102 @@
+  public static $modules = ['system', 'migrate_drupal'];

s/public/protected/

quietone’s picture

Title: [META] Migrate D7 i18n menu links » Migrate D7 i18n menu links
Issue summary: View changes
Status: Postponed » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new19.67 KB
new48.92 KB

Rerolling 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.

quietone’s picture

StatusFileSize
new2.25 KB
new48.72 KB

Some minor improvements.

daffie’s picture

Status: Needs review » Needs work

First quick review. Will do a second one.

  1. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -67,12 +76,48 @@ public function fields() {
    +          ->fields('ml')
    ...
    +        $source_mlid = $query->execute()->fetchField(1);
    

    Can we only select the field "mlid" instead of all fields. Can we then call the method fetchField() without any parameters.

  2. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -67,12 +76,48 @@ public function fields() {
    +    if ($row->hasSourceProperty('i18n_tsid')) {
    +      if ($row->getSourceProperty('i18n_tsid') != 0) {
    

    Can we change this to using a single if-statement?

  3. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -67,12 +76,48 @@ public function fields() {
    +        $default_language = $this->variableGet('language_default', (object) ['language' => 'en']);
    +        $default_language = $default_language->language;
    +        $row->setSourceProperty('language', $default_language);
    

    Why set the default language to "en" instead of "und"?

  4. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -80,6 +125,29 @@ public function prepareRow(Row $row) {
    +      $query = $this->select('i18n_string', 'i18n')->fields('i18n');
    +      $query->condition('i18n.textgroup', 'menu');
    +      $query->condition('i18n.type', 'item');
    +      $query->condition('i18n.objectid', $mlid);
    +      $results = $query->execute()->fetchAll();
    

    Can we rewrite this query to:

          $results = $this->select('i18n_string', 'i18n')
            ->fields('i18n')
            ->condition('textgroup', 'menu')
            ->condition('type', 'item')
            ->condition('objectid', $mlid)
            ->execute()
            ->fetchAll();
    
  5. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php
    @@ -0,0 +1,75 @@
    +      ->fields('ml')
    ...
    +    $source_mlid = $query->execute()->fetchField(1);
    

    Same as with MenuLink.

  6. +++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkLocalizedTest.php
    @@ -0,0 +1,97 @@
    +  protected function assertEntity($id, $langcode, $title, $menu, $description, $enabled, $expanded, array $attributes, $uri, $weight) {
    
    +++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTest.php
    @@ -80,11 +82,12 @@ protected function setUp(): void {
    +  protected function assertEntity($id, $langcode, $title, $menu, $description, $enabled, $expanded, array $attributes, $uri, $weight) {
    
    +++ b/core/modules/menu_link_content/tests/src/Kernel/Migrate/d7/MigrateMenuLinkTranslationTest.php
    @@ -0,0 +1,93 @@
    +  protected function assertEntity($id, $langcode, $title, $menu, $description, $enabled, $expanded, array $attributes, $uri, $weight) {
    

    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.

  7. +++ b/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php
    @@ -54,7 +54,9 @@ public function providerSource() {
    -        'description' => '',
    
    @@ -83,7 +85,9 @@ public function providerSource() {
    -        'description' => '',
    
    @@ -112,7 +116,9 @@ public function providerSource() {
    -        'description' => '',
    
    @@ -140,7 +146,9 @@ public function providerSource() {
    -        'description' => 'Test menu link 1',
    
    @@ -168,7 +176,9 @@ public function providerSource() {
    -        'description' => 'Test menu link 2',
    
    @@ -196,7 +206,40 @@ public function providerSource() {
    -        'description' => '',
    

    Why is the description value being removed?

  8. +++ b/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php
    @@ -217,7 +260,16 @@ public function providerSource() {
    +    $tests[0]['expected_data'][] = $expected[0];
    +    $tests[0]['expected_data'][] = $expected[1];
    +    $tests[0]['expected_data'][] = $expected[2];
    +    $tests[0]['expected_data'][] = $expected[6];
    +    $tests[0]['expected_data'][] = $expected[3];
    +    $tests[0]['expected_data'][] = $expected[4];
    

    I am missing the value $expected[5]. Can you explain why? Maybe adding adding a comment to the patch with the explanation.

  9. +++ b/core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/d7/MenuLinkLocalizedTest.php
    @@ -0,0 +1,222 @@
    +        'language' => 'unk',
    ...
    +        'language' => 'unk',
    

    Should it not be 'language' => 'und'?

naresh_bavaskar’s picture

Assigned: Unassigned » naresh_bavaskar
naresh_bavaskar’s picture

Assigned: naresh_bavaskar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new48.68 KB
new3.78 KB

I have tried to cover some of points from #82 comment, please review

quietone’s picture

Status: Needs review » Needs work

@naresh_bavaskar, to help reviewers and others working on this issue, please clarify which points from #82 have been addressed in #84.

naresh_bavaskar’s picture

@quitetone yeah, i have addressed point 1 to 5..
6 to 9 is pending.
I forgot to mention addressed points numbers.

daffie’s picture

Second review:

  1. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -80,6 +123,30 @@ public function prepareRow(Row $row) {
    +      $results = $this->select('i18n_string', 'i18n')->fields('i18n')
    

    Please put the part ->fields('i18n') on a separate line.

  2. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -80,6 +123,30 @@ public function prepareRow(Row $row) {
    +        ->condition('i18n.textgroup', 'menu')
    +        ->condition('i18n.type', 'item')
    +        ->condition('i18n.objectid', $mlid)
    

    The query is a single table query. The part "i18n." can be removed from each line.

  3. +++ b/core/modules/content_translation/migrations/d7_menu_links_localized.yml
    @@ -0,0 +1,46 @@
    +  description: options/attributes/title
    

    Why has the "description" this value? Other yml files don not have such a value.

  4. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -33,6 +33,15 @@ public function query() {
    +    if ($schema->fieldExists('menu_links', 'i18n_tsid')) {
    +      $query->addField('ml', 'i18n_tsid');
    +    }
    

    Why is this code added? All fields from the menu_links are already added to the query result.

  5. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php
    @@ -0,0 +1,75 @@
    +    $query->orderBy('ml.mlid');
    

    The order by for 'ml.mlid' is already added in the paretn query.

  6. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -67,12 +76,46 @@ public function fields() {
    +    if ($row->hasSourceProperty('ml_language')) {
    +      if (($row->getSourceProperty('ml_language') == 'und') && $this->hasTranslation($row->getSourceProperty('mlid'))) {
    

    Can we change this to a single if-statement. If not, then explain why not.

  7. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php
    @@ -0,0 +1,75 @@
    +  /**
    +   * The join options between the node and the node_revisions table.
    +   */
    +  const OPERATOR = '<>';
    

    Why is this constant added. It is not being used!

  8. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkTranslation.php
    @@ -0,0 +1,99 @@
    +  /**
    +   * Drupal 7 table name.
    +   */
    +  const I18N_STRING_TABLE = 'i18n_string';
    

    Why is this constant added. It is not being used!

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new6.58 KB
new47.59 KB

for #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.

Status: Needs review » Needs work

The last submitted patch, 88: 3008028-88.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new14.1 KB
new47.51 KB

#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.

quietone’s picture

StatusFileSize
new507 bytes
new47.5 KB

And 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

daffie’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
    @@ -67,12 +67,47 @@ public function fields() {
    +      $query = $this->select('menu_links', 'ml')
    +        ->fields('ml', ['mlid'])
    +        ->condition('i18n_tsid', $row->getSourceProperty('i18n_tsid'))
    +        ->orderBy('mlid')
    +        ->range(0, 1);
    +      $source_mlid = $query->execute()->fetchField();
    

    We can improve a little bit more by:

    +      $source_mlid = $this->select('menu_links', 'ml')
    +        ->fields('ml', ['mlid'])
    +        ->condition('i18n_tsid', $row->getSourceProperty('i18n_tsid'))
    +        ->orderBy('mlid')
    +        ->range(0, 1)
    +        ->execute()
    +        ->fetchField();
    
  2. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkTranslation.php
    @@ -0,0 +1,88 @@
    +  use I18nQueryTrait;
    ...
    +  const I18N_STRING_TABLE = 'i18n_string';
    

    The I18nQueryTrait does not use the constant I18N_STRING_TABLE.

  3. There are a number of coding standard violations that need to be fixed.
daffie’s picture

  1. +++ b/core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php
    @@ -0,0 +1,69 @@
    +    $query = $this->select('menu_links', 'ml')
    +      ->fields('ml', ['mlid'])
    +      ->condition('i18n_tsid', $row->getSourceProperty('i18n_tsid'))
    +      ->orderBy('mlid')
    +      ->range(0, 1);
    +    $source_mlid = $query->execute()->fetchField();
    

    Here we can also make it a little more better:

    +    $source_mlid = $this->select('menu_links', 'ml')
    +      ->fields('ml', ['mlid'])
    +      ->condition('i18n_tsid', $row->getSourceProperty('i18n_tsid'))
    +      ->orderBy('mlid')
    +      ->range(0, 1);
    +      ->execute()
    +      ->fetchField();
    
ravi.shankar’s picture

Assigned: Unassigned » ravi.shankar
ravi.shankar’s picture

Assigned: ravi.shankar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new47.33 KB
new5.2 KB

Here I have addressed comments #92.1, #92.3 and #93

daffie’s picture

Status: Needs review » Needs work

@ravi.shankar: Thank you for the updated patch!

Only the comment #92.2 is still open.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.75 KB
new47.31 KB

Addressing 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.

Status: Needs review » Needs work

The last submitted patch, 97: 3008028-97.patch, failed testing. View results

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new698 bytes
new47.31 KB

Seems 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.

daffie’s picture

Status: Needs review » Needs work

In the trait core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkTranslation.php we have the variable $i18nStringTable. Why do we then create a new constant called I18N_STRING_TABLE? Can we not use the variable from the trait and remove the constant I18N_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.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new1.45 KB
new47.2 KB

I'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.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

It is for me now RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 101: 3008028-101.patch, failed testing. View results

daffie’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC.

quietone’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1 KB
new47.21 KB

I do wish the status would change when a patch no longer applies.

Needed a reroll.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

As far as I can see this is a straight reroll. Back to RTBC.

  • Gábor Hojtsy committed ce767b8 on 9.1.x
    Issue #3008028 by quietone, bserem, naresh_bavaskar, ravi.shankar,...
gábor hojtsy’s picture

Title: Migrate D7 i18n menu links » [backport] Migrate D7 i18n menu links
Version: 9.1.x-dev » 9.0.x-dev
Status: Reviewed & tested by the community » Postponed

Looks 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.

alexpott’s picture

StatusFileSize
new883 bytes

This introduced a spelling mistake into core - we automate spellchecking. Here's a patch to fix this.

  • alexpott committed 75aba2e on 9.1.x
    Issue #3008028 follow-up: Migrate D7 i18n menu links
    
quietone’s picture

Adding 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.

  1. #3110669: Migrate d7 menu language content settings
  2. #3112249: Migrate d7 menu translation
  3. #3008028: Migrate D7 i18n menu links
jonathan1055’s picture

This commit https://git.drupalcode.org/project/drupal/commit/ce767b8 in #107 above has caused the new coding standards message

1 coding standards message
core/modules/content_translation/migrations/d7_menu_links_localized.yml
line 45	Expected 1 newline at end of file; 2 found

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?

jonathan1055’s picture

I have raised #3178338: Fix coding standard fail committed to core 9.1 and 9.2 to fix the coding standard fault reported above.

wim leers’s picture

9.1.0 was released nine days ago. I don't think backporting is still relevant?

Version: 9.0.x-dev » 9.1.x-dev

Drupal 9.0.10 was released on December 3, 2020 and is the final full bugfix release for the Drupal 9.0.x series. Drupal 9.0.x will not receive any further development aside from security fixes. Sites should update to Drupal 9.1.0 to continue receiving regular bugfixes.

Drupal-9-only bug reports should be targeted for the 9.1.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.2.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

benjifisher’s picture

Title: [backport] Migrate D7 i18n menu links » Migrate D7 i18n menu links
Issue summary: View changes

We 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.

benjifisher’s picture

Status: Postponed » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.