Error when removing a menu

Created on 1 March 2023, over 1 year ago

Problem/Motivation

When attempting to remove a menu that has been created for a group, I receive this error.

Drupal\Core\Entity\EntityStorageException: Some mandatory parameters are missing ("group") to generate a URL for route "entity.group_content_menu.canonical". in Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete() (line 761 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute('entity.group_content_menu.canonical', Object, Array) (Line: 132)
Drupal\Core\Routing\UrlGenerator->getPathFromRoute('entity.group_content_menu.canonical', Array) (Line: 68)
Drupal\Core\Render\MetadataBubblingUrlGenerator->getPathFromRoute('entity.group_content_menu.canonical', Array) (Line: 802)
Drupal\Core\Url->getInternalPath() (Line: 77)
redirect_entity_delete(Object)
call_user_func_array(Object, Array) (Line: 426)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'redirect') (Line: 405)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_delete', Object) (Line: 433)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_delete', Array) (Line: 251)
Drupal\Core\Entity\EntityStorageBase->invokeHook('delete', Object) (Line: 903)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('delete', Object) (Line: 496)
Drupal\Core\Entity\EntityStorageBase->delete(Array) (Line: 751)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete(Array) (Line: 347)
Drupal\Core\Entity\EntityBase->delete() (Line: 71)
Drupal\Core\Entity\ContentEntityDeleteForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 595)
Drupal\Core\Form\FormBuilder->processForm('group_content_menu_primary_group_menu_delete_form', Array, Object) (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
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: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 707)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

๐Ÿ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

๐Ÿ‡ซ๐Ÿ‡ฎFinland thatguy

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

Merge Requests

Comments & Activities

  • Issue created by @thatguy
  • ๐Ÿ‡ธ๐Ÿ‡ฎSlovenia alecsmrekar

    This is caused by the redirect module. The patch in here should fix it: https://www.drupal.org/project/redirect/issues/3314032 โ†’

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ซ๐Ÿ‡ฎFinland thatguy

    The patch from the linked redirect issue fixed this for me, thanks!

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom welly

    Not working for me unfortunately. I'm getting the same error with or without the patch.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom welly

    I've uninstalled redirect module and I still get the following error:

    Drupal\Core\Entity\EntityStorageException: Some mandatory parameters are missing ("group") to generate a URL for route "entity.group_content_menu.canonical". in Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete() (line 761 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
    Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute('entity.group_content_menu.canonical', Object, Array) (Line: 132)
    Drupal\Core\Routing\UrlGenerator->getPathFromRoute('entity.group_content_menu.canonical', Array) (Line: 68)
    Drupal\Core\Render\MetadataBubblingUrlGenerator->getPathFromRoute('entity.group_content_menu.canonical', Array) (Line: 802)
    Drupal\Core\Url->getInternalPath() (Line: 32)
    Drupal\path\Plugin\Field\FieldType\PathFieldItemList->computeValue() (Line: 33)
    Drupal\pathauto\PathautoFieldItemList->computeValue() (Line: 34)
    Drupal\path\Plugin\Field\FieldType\PathFieldItemList->ensureComputedValue() (Line: 15)
    Drupal\pathauto\PathautoFieldItemList->delegateMethod('preSave') (Line: 191)
    Drupal\Core\Field\FieldItemList->preSave() (Line: 938)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('preSave', Object) (Line: 888)
    Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 563)
    Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 753)
    Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 517)
    Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
    Drupal\Core\Entity\EntityBase->save() (Line: 294)
    Drupal\group\Entity\GroupRelationship::postDelete(Object, Array) (Line: 494)
    Drupal\Core\Entity\EntityStorageBase->delete(Array) (Line: 751)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete(Array) (Line: 347)
    Drupal\Core\Entity\EntityBase->delete() (Line: 101)
    Drupal\group_content_menu\Entity\GroupContentMenu::preDelete(Object, Array) (Line: 484)
    Drupal\Core\Entity\EntityStorageBase->delete(Array) (Line: 751)
    Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete(Array) (Line: 347)
    Drupal\Core\Entity\EntityBase->delete() (Line: 71)
    Drupal\Core\Entity\ContentEntityDeleteForm->submitForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 114)
    Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
    Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
    Drupal\Core\Form\FormBuilder->processForm('group_content_menu_subsite_menu_delete_form', Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    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: 169)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    

    So I don't think this is related to redirect.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom welly

    Just as an update, I also uninstalled pathauto, ran drush cr and I didn't get the error when deleting a menu link. So I guess it's all related somewhere. Will do some further investigation.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sumit-k

    I encountered the same issue and found that Patch #2 provided in the following link: https://www.drupal.org/project/redirect/issues/3314032 โ†’ resolved the issue effectively in my case. Additionally, I contributed another approach to handle exceptions within the same discussion thread.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Istari

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

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Istari

    I am facing nearly the same issue, but with another error message:

    I built a deriver for adding two static menu links for each group, which worked fine. The links are on the group available and are working.
    When clicking on the Edit button on /group/{gid}/menus the following warning appears:

    Warning: Undefined array key "url" in /var/www/html/web/modules/contrib/group_content_menu/src/Form/GroupContentMenuForm.php on line 322
    The website encountered an unexpected error. Try again later.
    
    Error: Call to a member function access() on null in Drupal\group_content_menu\Form\GroupContentMenuForm->buildOverviewTreeForm() (line 322 of modules/contrib/group_content_menu/src/Form/GroupContentMenuForm.php).

    This is shown in the browser as well in the recent log messages.
    When changing

    Drupal\group_content_menu\Form\GroupContentMenuForm->buildOverviewTreeForm() in line 322 from

    if (!$operation['url']->access()) {
      unset($operations[$key]);
    }
    

    to

    if (!empty($operation['url'])) {
        if (!$operation['url']->access()) {
           unset($operations[$key]);
        }
    }
    

    The error is solved.
    I am currently unsure if this issue is the right one, and I am also unsure if I should make a patch (haven't written a patch before, but I know the tutorials for it).

    Maybe you could help me.

  • Pipeline finished with Success
    4 months ago
    Total: 195s
    #232206
  • heddn Nicaragua

    I think the error you are facing is more closely related to ๐Ÿ› access() on null when permission is not properly configured. Needs work .

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Istari

    oh okay thank for the info.
    It is exactly the same solution with my patch.
    What is the next step now that the patch is no longer needed? Does the maintainer close the branch? Shall I delete it?

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance MacSim

    I had the same issue and after upgrading Redirect from 1.09 to 1.10 (which include the related patch in #2) the error is gone.

Production build 0.71.5 2024