Site crashes after clearing cache due to hasPermission() in GroupMenuConfigOverrides.php

Created on 2 December 2019, over 4 years ago
Updated 15 February 2023, over 1 year ago

After clearing the cache my site crashed. The error logs linked the caused to
Error: Call to a member function hasPermission() on null in Drupal\groupmenu\GroupMenuConfigOverrides->getUserGroupMenuIdsByGroupTypes() (line 213 of /var/www/drupal/apphome/modules/contrib/groupmenu/src/GroupMenuConfigOverrides.php)

I'm not sure why this is an issue now as clearing the cache didn't affect it before. Commenting the if statement fixed the issue but I'm not sure what other issues may arise as a result. Here is the stackflow below.

Error: Call to a member function hasPermission() on null in Drupal\groupmenu\GroupMenuConfigOverrides->getUserGroupMenuIdsByGroupTypes() (line 213 of /var/www/drupal/apphome/modules/contrib/groupmenu/src/GroupMenuConfigOverrides.php) #0 /var/www/drupal/apphome/modules/contrib/groupmenu/src/GroupMenuConfigOverrides.php(111): Drupal\groupmenu\GroupMenuConfigOverrides->getUserGroupMenuIdsByGroupTypes(Array) #1 /var/www/drupal/apphome/core/lib/Drupal/Core/Config/ConfigFactory.php(209): Drupal\groupmenu\GroupMenuConfigOverrides->loadOverrides(Array) #2 /var/www/drupal/apphome/core/lib/Drupal/Core/Config/ConfigFactory.php(169): Drupal\Core\Config\ConfigFactory->loadOverrides(Array) #3 /var/www/drupal/apphome/core/lib/Drupal/Core/Config/ConfigFactory.php(136): Drupal\Core\Config\ConfigFactory->doLoadMultiple(Array) #4 /var/www/drupal/apphome/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(188): Drupal\Core\Config\ConfigFactory->loadMultiple(Array) #5 /var/www/drupal/apphome/core/lib/Drupal/Core/Entity/EntityStorageBase.php(292): Drupal\Core\Config\Entity\ConfigEntityStorage->doLoadMultiple(NULL) #6 /var/www/drupal/apphome/core/lib/Drupal/Core/Entity/EntityBase.php(541): Drupal\Core\Entity\EntityStorageBase->loadMultiple(NULL) #7 /var/www/drupal/apphome/modules/contrib/group/modules/gnode/src/Routing/GroupNodeRouteProvider.php(19): Drupal\Core\Entity\EntityBase::loadMultiple() #8 [internal function]: Drupal\gnode\Routing\GroupNodeRouteProvider->getRoutes() #9 /var/www/drupal/apphome/core/lib/Drupal/Core/Routing/RouteBuilder.php(146): call_user_func(Array) #10 /var/www/drupal/apphome/core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild() #11 /var/www/drupal/apphome/core/includes/common.inc(1170): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() #12 /var/www/drupal/apphome/modules/contrib/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php(191): drupal_flush_all_caches() #13 [internal function]: Drupal\admin_toolbar_tools\Controller\ToolbarController->flushAll() #14 /var/www/drupal/apphome/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #15 /var/www/drupal/apphome/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #16 /var/www/drupal/apphome/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #17 /var/www/drupal/apphome/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #18 /var/www/drupal/apphome/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #19 /var/www/drupal/apphome/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #20 /var/www/drupal/apphome/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/drupal/apphome/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/drupal/apphome/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /var/www/drupal/apphome/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /var/www/drupal/apphome/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /var/www/drupal/apphome/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /var/www/drupal/apphome/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /var/www/drupal/apphome/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /var/www/drupal/apphome/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #29 {main}.

πŸ› Bug report
Status

Fixed

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bajah1701

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

Comments & Activities

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States dasginganinja Bethlehem, PA

    I just wanted to add another comment on to this.

    We observed this behavior on our site when we used Backup & Migrate to fetch the databases from production for local development.

    The default profile for this excluded a lot of the data from the `cache_*` tables, however `cache_groupmenu` wasn't included in there and was causing this issue for us.

    Running Cron or Update.php seemed to resolve it before we knew what the issue was. The odd thing is that a cache clear didn't clear these tables :)

  • πŸ‡ΊπŸ‡ΈUnited States dasginganinja Bethlehem, PA

    I was still running into this even after the upgrade to 1.0-beta3.

    Even though $group_content wasn't null, $group_content->getGroup() returned NULL.

    Attached is a patch to handle this situation. I'm not sure if there are any unintended side effects, but this made a site without cached entities work again.

    This appears to happen during drupal_rebuild()

Production build 0.69.0 2024