Fatal error when un-checking the "Provide a menu link" checkbox on a node form

Created on 23 June 2021, about 4 years ago
Updated 8 July 2025, 5 days ago

Problem/Motivation

When you try to uncheck the "Provide a menu link" checkbox on a node having a menu link, you get the following error:

Error: Call to a member function delete() on null in menu_ui_form_node_form_submit() (line 335 of core/modules/menu_ui/menu_ui.module).
menu_ui_form_node_form_submit(Array, Object)
call_user_func_array('menu_ui_form_node_form_submit', Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('node_FOO_edit_form', Array, Object) (Line: 321)

If you reload the page, you would realize the menu_link had been successfully deleted

The reason is the menu_ui_form_node_form_submit() function being executed twice. So during the second call the menu link is already deleted.

Steps to reproduce

- Install the module
- Create a node with a menu link
- Edit the node and uncheck the "Provide a menu link" checkbox
- save

Proposed resolution

Remove the code adding the 'menu_ui_form_node_form_submit' as a submit callback, because that function is already un the #submit stack

Remaining tasks

Test & review

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Closed: duplicate

Version

1.0

Component

Code

Created by

🇪🇸Spain akalam

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024