Problem/Motivation

preprocessBreadcrumb hook fails when loading a MenuLinkContent entity.

Other entities such as block_content might fail as well.

      $entity_type = $entity->getEntityType();
      $type_label = $entity_type->getSingularLabel();
      $bundle_key = $entity_type->getKey('bundle');

      if ($bundle_key) {
        $bundle_entity = $entity->get($bundle_key)->entity;
        $type_label = $bundle_entity->label();
      }

The problem is that these entities declare a bundle entity key but no bundle_entity_type. Such entity types get a plain string bundle field rather than an entity_reference, so $entity->get($bundle_key)->entity is always NULL.

Steps to reproduce

- Visit a page which has a menu_link_content entity on the breadcrumb route.
- Miserably fail.

Proposed resolution

Add a check for the existence of an actual entity.

Remaining tasks

Code it

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

Issue fork drupal-3621961

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

idiaz.roncero created an issue. See original summary.

idiaz.roncero’s picture

Status: Active » Closed (duplicate)

Closing, i see this has been corrected on main and had its issue

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.