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, edits the node and then saves 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 doesn't have permissions to manage links for that menu.
3. Save the node.
4. See the menu link is no longer on the menu.

CommentFileSizeAuthor
#7 3523073_7.patch1013 bytesrakesh.regar
#7 after.png205.81 KBrakesh.regar
#7 before.png164.11 KBrakesh.regar
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

juanolalla created an issue. See original summary.

juanolalla’s picture

Issue summary: View changes

rakesh.regar made their first commit to this issue’s fork.

rakesh.regar’s picture

Status: Active » Needs review
juanolalla’s picture

Status: Needs review » Needs work

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)
rakesh.regar’s picture

Status: Needs work » Needs review
StatusFileSize
new164.11 KB
new205.81 KB
new1013 bytes

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!

juanolalla’s picture

Status: Needs review » Reviewed & tested by the community

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.
    
ewout goosmann’s picture

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.

ewout goosmann’s picture

ewout goosmann’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.