Menu link exception on non-default revision

Created on 7 August 2025, 10 days ago

Problem/Motivation

When a node has a default revision and an associated menu link, creating a new revision without setting it as the default revision leaves the menu link unchanged, as expected.

However, when both the token and menu_ui modules are enabled, saving the draft triggers an update on the menu link. Since the node revision is not marked as default, this results in an inconsistency, and an exception is thrown during the menu link update process.

Drupal\Core\Entity\EntityStorageException: An existing default revision of the 'menu_link_content' entity type can not be changed to a non-default revision. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal\Core\Entity\EntityStorageBase->save() (Line: 804)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 370)
Drupal\Core\Entity\EntityBase->save() (Line: 726)
token_node_menu_link_submit()

Steps to reproduce

  1. Create a node, add a menu link to it, and publish it.
  2. Edit the content and create a new revision as draft.
  3. Save the draft.
  4. 💥

Tested on Drupal 11.2.2 with Token 1.15.0.

Proposed resolution

Mark the menu link entity for a new revision if the node's current revision is not the default one.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.15

Component

Code

Created by

🇫🇷France johnatas

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

Comments & Activities

  • Issue created by @johnatas
  • 🇫🇷France johnatas

    Attached patch fixes the issue on my end.
    So far, I haven't noticed any side effects, but I'll continue testing and report back if anything comes up.

  • 🇺🇸United States chinnu76

    I can reproduce the issue and confirm that the patch allows you to bypass the error

  • 🇺🇸United States leraa

    I can confirm this patch worked on my 11.2.2 site where content moderation was blowing up on content types using menu link.

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

    Hello,

    I've tested this as well and I can confirm that this patch resolves the issue when you're using Drupal 11.2.x and Token 1.15.0.

    However out of curiosity I've tested the same issue with Drupal 11.1.8 and Token 1.15.0 and I couldn't reproduce this issue using the same steps.
    So I don't think this issue is happening due to something being wrong with this module, but rather a change made in Drupal core from 11.1.8 to ^11.2. I've investigated a bit what this change may be, but haven't been able to find it.

    I've opened a MR for this, by applying patch provided in #2 🐛 Menu link exception on non-default revision Active for easier merging and test coverage. Tests are currently failing on dev branch so it might be worth fixing them first and then merging and reviewing this issue. Updating status to needs review.

Production build 0.71.5 2024