- Issue created by @joelpittet
After uninstalling a custom entity-type module, the Admin Toolbar (admin_toolbar_tools) crashes. A derived menu link plugin still references the now-missing entity type and causes a fatal when the toolbar renders.
resource_type
).The website encountered an unexpected error. Try again later. Drupal\Component\Plugin\Exception\PluginNotFoundException: The "resource_type" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 142 of core/lib/Drupal/Core/Entity/EntityTypeManager.php). Drupal\Core\Entity\EntityTypeManager->getHandler() (Line: 195) Drupal\Core\Entity\EntityTypeManager->getStorage() (Line: 38) Drupal\admin_toolbar_tools\Plugin\Menu\MenuLinkEntity::create() (Line: 21) Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 194) Drupal\Core\Menu\MenuLinkManager->createInstance() (Line: 130) Drupal\Core\Menu\MenuLinkTree->createInstances() (Line: 125) Drupal\Core\Menu\MenuLinkTree->createInstances() (Line: 107) Drupal\Core\Menu\MenuLinkTree->load() (Line: 118) Drupal\toolbar\Controller\ToolbarController::preRenderGetRenderedSubtrees() call_user_func_array() (Line: 113) Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 886) Drupal\Core\Render\Renderer->doCallback() (Line: 431) Drupal\Core\Render\Renderer->doRender() (Line: 248) Drupal\Core\Render\Renderer->render() (Line: 283) {closure}() (Line: 637) Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 282) toolbar_get_rendered_subtrees() (Line: 295) _toolbar_get_subtrees_hash() (Line: 168) toolbar_toolbar() Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 191) Drupal\toolbar\Element\Toolbar::preRenderToolbar() ... omitted for brevity ...
admin_toolbar_tools
, guard against missing entity types. In the deriver and/or in Plugin\Menu\MenuLinkEntity::create()
, check entity_type.manager->hasDefinition($entity_type_id)
before calling getStorage()
; skip creating the plugin if not found.\Drupal::service('plugin.manager.menu.link')->rebuild();
PluginNotFoundException
and return no derivatives).Active
3.0
Code