Fieldable entities without bundles throw an exception.

Created on 24 August 2021, over 3 years ago
Updated 17 September 2024, 3 months ago

Problem/Motivation

With the Workbench Moderation module enabled you can no longer edit fieldable entities that don't have bundles.

Steps to reproduce

  1. Enable the Workbench Moderation module.
  2. Enabled the Paragraphs Library sub-module that comes with the Paragraphs module.
  3. Go to /admin/content/paragraphs and click Add Library Item.

You'll receive the standard "The website encountered an unexpected error. Please try again later." error and if you check in the logs you'll see an error that reads Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist.

Proposed resolution

The code causing the problem is in src/Plugin/Field/FieldWidget/ModerationStateWidget.php. It's attempting to load the entity type from storage, but is assuming it has a bundle.

$bundle_entity = $this->entityTypeManager->getStorage($entity->getEntityType()->getBundleEntityType())->load($entity->bundle());

Since "$entity->getEntityType()->getBundleEntityType()" is empty, it generates the above error. Proposed resolution is to simply check if the bundle entity type is blank and use the entity type id function instead for that situation. That's what the attached patch does.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jacobbell84

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.

Production build 0.71.5 2024