Error "You can only change the parent menu link for the published version of this content"

Created on 13 May 2024, 10 months ago

Problem/Motivation

Menu problems occur when editing page nodes with a langcode of 'und' (undefined) and using content moderation.

The error 'You can only change the parent menu link for the published version of this content' appears incorrectly when creating a draft of a published page that has a menu entry.

The problem occurs because a menu revision is created with the same langcode as the page node ('und'), whereas the rest of the menu structure has a langcode of 'en'. This means that joins fail when retrieving the menu information from the database and the 'parent' menu item is not set correctly when viewing the node edit form.

This happened in our databases because the page nodes were migrated from Drupal 7 (and langcode was set to 'und') whereas the menu structure was built in Drupal 10 (and has langcode of 'en').

Proposed resolution

Amend the code in _menu_ui_node_save so that the langcode of the menu entity is never changed to the langcode of the node. (We are only talking about editing existing menu entries here, so the langcode will always have been set correctly by the call to MenuLinkContent::load at the start of _menu_ui_node_save and it will never be necessary to change it.)

🐛 Bug report
Status

Active

Version

10.2

Component
Menu system 

Last updated about 22 hours ago

Created by

🇬🇧United Kingdom duttonma

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024