Nodes loose menu link when saved without menu permissions

Created on 7 May 2025, about 1 month ago

Problem/Motivation

When a node already has a menu link provided, and an user who doesn't have permissions to add, or edit links for that menu, edit the node and then save it, the menu link disappears from the menu. This is not Drupal core's behavior, if an user just has permissions to edit the content of the node, but not the menu link, it should be kept.

Steps to reproduce

1. Install simple_menu_permissions.
2. Edit a node with a menu link with an user that does't have permissions for to manage links for that menu.
3. Save a node.
4. See the menu link is no longer on the menu.

๐Ÿ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain juanolalla

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

Merge Requests

Comments & Activities

  • Issue created by @juanolalla
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rakesh.regar Rajasthan, India

    rakesh.regar โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rakesh.regar Rajasthan, India
  • ๐Ÿ‡ช๐Ÿ‡ธSpain juanolalla

    Thanks @rakesh.regar, but didn't work. Same result.

    These are the error messages (same as before) thrown after saving the node:

    Warning: Undefined array key "menu_name" in token_node_menu_link_submit() (line 722 of modules/contrib/token/token.module).
    
    token_node_menu_link_submit()
    call_user_func_array() (Line: 307)
    Drupal\Core\Entity\EntityForm->buildEntity() (Line: 155)
    Drupal\Core\Entity\ContentEntityForm->buildEntity() (Line: 286)
    Drupal\Core\Entity\EntityForm->submitForm() (Line: 145)
    Drupal\Core\Entity\ContentEntityForm->submitForm()
    call_user_func_array() (Line: 129)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
    Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 619)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 335)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
    Warning: Undefined array key "parent" in token_node_menu_link_submit() (line 723 of modules/contrib/token/token.module).
    
    token_node_menu_link_submit()
    call_user_func_array() (Line: 307)
    Drupal\Core\Entity\EntityForm->buildEntity() (Line: 155)
    Drupal\Core\Entity\ContentEntityForm->buildEntity() (Line: 286)
    Drupal\Core\Entity\EntityForm->submitForm() (Line: 145)
    Drupal\Core\Entity\ContentEntityForm->submitForm()
    call_user_func_array() (Line: 129)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
    Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 619)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 335)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
    Warning: Undefined array key "menu_name" in _menu_ui_node_save() (line 122 of core/modules/menu_ui/menu_ui.module).
    
    _menu_ui_node_save() (Line: 349)
    menu_ui_form_node_form_submit()
    call_user_func_array() (Line: 129)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
    Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 619)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 335)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
    Warning: Undefined array key "parent" in _menu_ui_node_save() (line 123 of core/modules/menu_ui/menu_ui.module).
    
    _menu_ui_node_save() (Line: 349)
    menu_ui_form_node_form_submit()
    call_user_func_array() (Line: 129)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
    Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 619)
    Drupal\Core\Form\FormBuilder->processForm() (Line: 335)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rakesh.regar Rajasthan, India

    Hi @juanolalla,

    I'm not sure why it's not working on your end. When I tried to replicate the issue, I encountered the same errors you mentioned. However, after applying the patch, all four errors were resolved, and the menu link remained intact after saving the node.

    It's possible that something was missed during the manual patching process. To help, Iโ€™m attaching the patch file along with before-and-after screenshots for reference.

    Please give it another try and let me knowโ€”I've tested it in multiple scenarios and it worked as expected.

    Thanks!

  • ๐Ÿ‡ช๐Ÿ‡ธSpain juanolalla

    Thank you @rakesh.regar, you are right, sorry, I made a mistake while testing it. It works indeed.

    • 9e034bb8 committed on 3.x
      Issue #3523073 :Menu item looses link on node save.
      
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Ewout Goosmann

    Thank you @juanolalla for reporting this issue and thank you @rakesh.regar for providing a solution. I was able to reproduce the issue myself and the changes in the MR fix the issue. The MR is merged into the new 3.0.1 release.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Ewout Goosmann
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Ewout Goosmann
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024