Menu link title is not updated when related node revision is published

Created on 21 September 2021, almost 3 years ago
Updated 17 July 2024, about 2 months ago

Problem/Motivation

When menu link title is changed as part of the creation of the new revision on the node edit form that is not published this change is not published when the revision is published from another place, like the "Latest version" page.

Steps to reproduce

Install Drupal using Standard profile
Enable Content Moderation module
Apply Editorial workflow to the Page content type
Create a Page "Test page" node, add it to the main me and publish it
Create a draft of the "Test page" node by changing content and change menu link title to "Test page changed"
Publish the draft from the "Latest version" page

Expected result

Main menu has "Test page changed" link pointing to "Test page" node.

Actual result

Main menu has "Test page" link pointing to "Test page" node.

Proposed resolution

Fix the bug.

Remaining tasks

Add test that would expose the bug
Add fix
Review
Commit

User interface changes

None

API changes

TBC

Data model changes

TBC

Release notes snippet

TBD

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 23 minutes ago

Created by

πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

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.

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    I took a closer look at this today, sharing my findings as I was a bit confused by the flow.

    Following the steps to reproduce I wanted to see what was happening when I got to the step:

    Create a draft of the "Test page" node by changing content and change menu link title to "Test page changed"

    When the node form is submitted the _menu_ui_node_save function is called which updates the menu item.

    Specifically at https://git.drupalcode.org/project/drupal/-/blob/11.0.0-rc1/core/modules... it is setting the isDefaultRevision to match the $node - in this case the $node is a new draft revision and which is not the default and so the menu link content is set as not the default revision.

    However a new revision is not created for the menu link content - so when the entity storage handler saves the content it

    • leaves the original title in menu_link_content_data
    • saves the new title in menu_link_content_field_revision with the same revision id

    I am not sure if this is expected but it seems very odd to have different data in the revision table and base table with the same revision id? I then found it had been previously mentioned in the related issue https://www.drupal.org/project/drupal/issues/3065180#comment-14052155 β†’

    I briefly experiment with creating a new forward revision of the menu item when the node is saved as per that related issue - but that seemed to open up a whole new can on worms. The menu tree can't be reordered if there is a forward revision of any menu link content and there is no UI to view these.

    Another other approach which I looked at was calling _menu_ui_node_save again with the default values as part of the moderation form submit. This works as it basically replicates what the menu ui is loading and saving if this was published via the node form itself - but it feels like a odd thing to be doing - but if the revision behaviour is expected then it could be simple change.

Production build 0.71.5 2024