Problem/Motivation

After install this module, when i want to remove menu item from my node i have got this error:

Error: Call to a member function delete() on null in menu_ui_form_node_form_submit() (line 374 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: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('node_content_type_page_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('node_content_type_page_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 135)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 57)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

I can see that menu_item_extras attach service "menu_item_extras.menu_link_content_helper" in line 309, which do the same like function menu_ui_form_node_form_submit() in core menu_ui module, but core do not check if $entity object is not null.

API changes

  • Detach this services?
  • Fix this issue

Comments

lamp5 created an issue. See original summary.

voleger’s picture

Assigned: Unassigned » voleger
Status: Active » Needs work

Yes, there are few submit callbacks that handle creation menu link of the node in the related bundle.
So in that situation, it is better to remove deletion logic from the module and keep that task for node callback.
I will update dev ASAP.

  • voleger committed 4bd5bde on 8.x-2.x
    Issue #2941680: Call to a member function delete()
    
voleger’s picture

Assigned: voleger » Unassigned
Status: Needs work » Fixed

This fix in the 8.x-2.x-dev branch.

hussainweb’s picture

@voleger, thanks for fixing the issue. How about creating a new release so that we don't have to move to dev version? I think an error like this warrants another release as there are no workarounds on the current stable version.

hussainweb’s picture

I see that we have a new release with this fix. Thank you!

voleger’s picture

Status: Fixed » Closed (fixed)