Fatal when editing a paragraph_block field

Created on 4 July 2025, 11 days ago

Problem/Motivation

When editing a field in admin/structure/block-content/manage/paragraph_block/fields, i get the following error:

Warning: Undefined variable $paragraph_type in /var/www/html/web/modules/contrib/paragraph_block/src/Entity/Storage/CustomBlockContentStorage.php on line 102
The website encountered an unexpected error. Try again later.

Drupal\Core\Entity\EntityStorageException: Missing bundle for entity type paragraph in Drupal\Core\Entity\ContentEntityStorageBase->doCreate() (line 125 of core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).
Drupal\Core\Entity\ContentEntityStorageBase->create() (Line: 101)
Drupal\paragraph_block\Entity\Storage\CustomBlockContentStorage->doCreate() (Line: 94)
Drupal\Core\Entity\ContentEntityStorageBase->create() (Line: 46)
_field_create_entity_from_ids() (Line: 113)
Drupal\field_ui\Form\FieldStorageConfigEditForm->form() (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm() (Line: 84)
Drupal\field_ui\Form\FieldStorageConfigEditForm->buildForm() (Line: 164)
Drupal\field_ui\Form\FieldConfigEditForm->form() (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm() (Line: 68)
Drupal\form_decorator\FormDecoratorBase->buildForm() (Line: 55)
Drupal\sites_group_overrides\FormDecorator\TargetConfigFields->buildForm() (Line: 68)
Drupal\form_decorator\FormDecoratorBase->buildForm() (Line: 57)
Drupal\sites_group_overrides\FormDecorator\ConfigFields->buildForm()
call_user_func_array() (Line: 528)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 54)
Drupal\sites\SitesTrustedHostsMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 53)
Asm89\Stack\Cors->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

This is caused by CustomBlockContentStorage::doCreate with this code:

$paragraph = $this->entityTypeManager->getStorage('paragraph')->create([
          'type' => $paragraph_type,
        ]);

Proposed resolution

The first question is, why is this method (even the whole class) called at all? As we want to edit a paragraph_block field, it seems highly unwanted to create any paragraph_block entity.
So a proper solution would be to avoid that.

For a quick solution, another way is to ensure that no null values can be passed to the create() method, which in my case avoids this error.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany drupatz

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024