Prism causes WSOD on field creation for all field types

Created on 4 December 2024, about 2 months ago

Problem/Motivation

Enabling the Prism module causes a WSOD when attempting to create a new field for any content type via the UI on admin/structure/types/manage/project/fields/add-field. It reports the following message:

TypeError: Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 45 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

This error seems highly related to the discussion in this issue: https://www.drupal.org/project/drupal/issues/3475505 🐛 Changes in site building process can run into Cannot access offset of type StringTranslation\TranslatableMarkup on field creation path Active

Steps to reproduce

  1. Launch a fresh drupal site
  2. Install and enable the Prism module
  3. Attempt to create a new field on any content type via the UI, e.g at admin/structure/types/manage/project/fields/add-field

Proposed resolution

The problem appears to be stemming from line 17 of prism/src/Plugin/Field/FieldType/TextPrismItem.php, where the FieldType definition category uses a Translation instead of a string:

/**
 * Plugin implementation of the 'text_long_prism' field type.
 *
 * @FieldType(
 *   id = "text_long_prism",
 *   label = @Translation("Text (prism)"),
 *   description = @Translation("This field stores long text in the database."),
 *   category = @Translation("Text"),
 *   default_widget = "text_prism",
 *   default_formatter = "prism_default"
 * )
 */

If you remove the translation (or the category entirely), it fixes the issue completely. I'm not completely au fait with what the allowed schema for FieldType is, and whether or not 'category' is supposed to allow Translations.

Nevertheless, the following prevents the WSOD:

/**
 * Plugin implementation of the 'text_long_prism' field type.
 *
 * @FieldType(
 *   id = "text_long_prism",
 *   label = @Translation("Text (prism)"),
 *   description = @Translation("This field stores long text in the database."),
 *   category = "Text",
 *   default_widget = "text_prism",
 *   default_formatter = "prism_default"
 * )
 */

Remaining tasks

Full error log

The website encountered an unexpected error. Try again later.

TypeError: Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 45 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Drupal\Core\Plugin\DefaultPluginManager->getDefinition(Object) (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance(Object, Array) (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance(Object, Array) (Line: 136)
Drupal\field_ui\Form\FieldStorageAddForm->processFieldDefinitions(Object) (Line: 80)
Drupal\field_ui\Form\FieldStorageAddForm->buildForm(Array, Object, 'node', 'project')
call_user_func_array(Array, Array) (Line: 528)
Drupal\Core\Form\FormBuilder->retrieveForm('field_ui_field_storage_add_form', Object) (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
🐛 Bug report
Status

Active

Version

2.2

Component

Code

Created by

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