TypeError when deleting a content type

Created on 31 July 2025, 13 days ago

Problem/Motivation

When I delete a content type I get this exception:

TypeError: Cannot assign null to property Drupal\navigation_extra\Plugin\Menu\TranslatedMenuLink::$entity of type Drupal\Core\Entity\EntityInterface in Drupal\navigation_extra\Plugin\Menu\TranslatedMenuLink->__construct() (line 49 of modules/contrib/navigation_extra/src/Plugin/Menu/TranslatedMenuLink.php).
Drupal\navigation_extra\Plugin\Menu\TranslatedMenuLink->__construct() (Line: 62)
Drupal\navigation_extra\Plugin\Menu\TranslatedMenuLink::create() (Line: 21)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 196)
Drupal\Core\Menu\MenuLinkManager->createInstance() (Line: 91)
Drupal\Core\Menu\MenuLinkTree->createInstances() (Line: 86)
Drupal\Core\Menu\MenuLinkTree->createInstances() (Line: 68)
Drupal\Core\Menu\MenuLinkTree->load() (Line: 86)
Drupal\navigation\Plugin\Block\NavigationMenuBlock->build() (Line: 106)
Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 90)
Drupal\layout_builder\SectionComponent->toRenderArray() (Line: 88)
Drupal\layout_builder\Section->toRenderArray() (Line: 123)
Drupal\navigation\NavigationRenderer->doBuildNavigation()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 871)
Drupal\Core\Render\Renderer->doCallback() (Line: 409)
Drupal\Core\Render\Renderer->doRender() (Line: 245)
Drupal\Core\Render\Renderer->doRenderRoot() (Line: 141)
Drupal\Core\Render\Renderer->{closure:Drupal\Core\Render\Renderer::renderInIsolation():140}() (Line: 622)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 140)
Drupal\Core\Render\Renderer->renderInIsolation() (Line: 167)
Drupal\Core\Render\Renderer->doRenderPlaceholder() (Line: 204)
Drupal\Core\Render\Renderer->renderPlaceholder() (Line: 730)
Drupal\big_pipe\Render\BigPipe->renderPlaceholder() (Line: 500)
Drupal\big_pipe\Render\BigPipe->{closure:Drupal\big_pipe\Render\BigPipe::sendPlaceholders():500}()
Fiber->start() (Line: 507)
Drupal\big_pipe\Render\BigPipe->sendPlaceholders() (Line: 256)
Drupal\big_pipe\Render\BigPipe->sendContent() (Line: 116)
Drupal\big_pipe\Render\BigPipeResponse->sendContent() (Line: 397)
Symfony\Component\HttpFoundation\Response->send() (Line: 20)

Steps to reproduce

Go to content type with Navigation Extra enabled and delete one

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly maicol07

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

Merge Requests

Comments & Activities

  • Issue created by @maicol07
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinodhini.e chennai

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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinodhini.e chennai

    Hi, I have tested this module on Drupal 11.2.2.

    I encountered a fatal error when an entity referenced in a menu item was deleted.

    To resolve this, I updated the TranslatedMenuLink.php file by making the $entity property nullable and adding a check to ensure both entity_type and entity_id are set before attempting to load the entity.

    This avoids the TypeError when the entity is missing or deleted and ensures graceful fallback behavior for title, description, and cache methods.

    After applying the changes, the issue is resolved and the menu works correctly without throwing errors.

    Please review and let me know if anything further needs to be added or adjusted. Thanks.

  • Pipeline finished with Success
    13 days ago
    Total: 445s
    #561526
  • Confirming the fix as described in the comment above. Applied the patch, deleted the Article content type on a fresh D10.5.1 installation. No errors.

Production build 0.71.5 2024