entity type does not exist

Created on 13 April 2023, over 1 year ago
Updated 2 June 2024, 7 months ago

Problem/Motivation

Installed in Drupal 10 and visiting /admin/config/content/taxonomy_set_lineage throws a WSOD with the error,

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of /home/public_html/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇳🇬Nigeria chike Nigeria

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

Comments & Activities

  • Issue created by @chike
  • 🇧🇪Belgium vodde83

    This seems to be due to $bundle_entity_type = $this->entityTypeManager->getDefinition($entity_type)->get('bundle_entity_type') in TaxonomySetLineageForm returning NULL.

    This subsequently causes the next line : $entity_bundle = $this->entityTypeManager->getStorage($bundle_entity_type)->load($bundle_id); to fail.

    For now, I fixed it locally by adding an IF-statement around it.
    Basically, replace this block of code:

            $bundle_entity_type = $this->entityTypeManager->getDefinition($entity_type)->get('bundle_entity_type');
            $entity_bundle = $this->entityTypeManager->getStorage($bundle_entity_type)->load($bundle_id);
            $options_bundles[$bundle_id] = $entity_label . ' - ' . $entity_bundle->label();
    
            $options_fields[$instance->id()] = $instance->label() . ' <small>(' . $instance->id() . ')</small>';
    

    with:

            if ($bundle_entity_type = $this->entityTypeManager->getDefinition($entity_type)->get('bundle_entity_type')) {
              $entity_bundle = $this->entityTypeManager->getStorage($bundle_entity_type)->load($bundle_id);
              $options_bundles[$bundle_id] = $entity_label . ' - ' . $entity_bundle->label();
    
              $options_fields[$instance->id()] = $instance->label() . ' <small>(' . $instance->id() . ')</small>';
            }
    

    I do seem to have some other - likely unrelated - issues with the module, but at least that will grant you access to the configuration form.

  • 🇫🇷France opi

    Could not reproduce on a almost fresh D10 instance. Could it be possible that you have some field that is not attach to any bundle, or maybe a custom entity without bundles, or any specific case ?

    @maintainers : do you want me to provide a patch with additional checks for NULL variables ?

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India viren18febS

    I have resolved the issue & added patch, please review.

  • Status changed to Needs work about 1 year ago
  • 🇫🇷France opi

    You're patch seems OK but there's one issue regarding coding standards. Please add a space before the opening brackets of your if condition.

  • 🇮🇳India viren18febS

    Update the previous #5 🐛 entity type does not exist Needs work patch!

  • Status changed to RTBC about 1 year ago
  • 🇫🇷France opi

    thanks!

  • 🇳🇬Nigeria chike Nigeria

    Patch #7 is working. Thanks.

Production build 0.71.5 2024