Menu link of default language overwritten by translations if translation not enabled

Created on 8 August 2016, over 8 years ago
Updated 6 November 2024, 15 days ago

Problem/Motivation

The menu link of the default language is overwritten if you add/edit a translation, if translation isn't enabled for menu links.

Steps to reproduce:

  • Enable the translation for a content type;
  • Do not enable translation for menu links;
  • Create a node in default language and on the node creation form, click "Provide a menu link" and add a menu link;
  • Translate this node and translate the menu link.

The menu link of the default language will be overwritten by the changes made to the menu link on the translated node.

Proposed resolution

A fix to this was provided in #2769705: Menu link of default language overwritten by translations if token module installed , but the changes should be done in Core. Otherwise, we need to warn the user of this by appending a "(all languages)" to "Provide a menu link".

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component

menu_ui.module

Created by

🇨🇦Canada Bambell

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • @alecsmrekar opened merge request.
  • 🇸🇮Slovenia alecsmrekar

    I opened a merge request that addresses this with a new approach. Simply, if a menu link is not translatable, the code should not be setting a language on the menu link entity.

    Here are some test step that fail without the fix applied:
    1. drush si
    2. drush en -y workspaces content_translation
    3. drush uli
    4. Go to /admin/config/regional/language and add the Spanish language
    5. Go to /admin/config/regional/content-language and enable translation for "Content", ensure to check "Article" under the "Content" fieldset
    6. Switch to the Stage workspace
    7. Create a new Article, check "Provide a menu link" and save
    8. Go to /es/node/{}/translations and add a Spanish translation
    9. Note the revision ID: drush sqlq "select MAX(revision_id) from menu_link_content_field_revision"
    10. Run drush php:eval 'echo \Drupal::entityTypeManager()->getStorage("menu_link_content")->loadRevision(REVISION_ID)->getMenuName()'

    Notice that without the fix, the menu name comes blank, but with the fix, it prints the menu name.

  • 🇸🇮Slovenia alecsmrekar

    The test fail does not seem related to this:
    Drupal\Tests\image\Functional\ImageStylesPathAndUrlTest 0 passes 84s 1 fails

  • 🇮🇹Italy plach Venezia

    Looks good to me but we need tests: converting #31 would be a good start :)

Production build 0.71.5 2024