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

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"
 * )
 */

See: https://www.drupal.org/node/3375748

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)

Issue fork prism-3491768

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

jackwrfuller created an issue. See original summary.

jackwrfuller’s picture

Priority: Normal » Major

jackwrfuller’s picture

jackwrfuller’s picture

jackwrfuller’s picture

I have been made aware of this change record: https://www.drupal.org/node/3375748, so it looks that I was right, and the change I made is the correct one to comply with the new API.

jackwrfuller’s picture

Issue summary: View changes
jackwrfuller’s picture

Status: Active » Needs review
eojthebrave’s picture

Status: Needs review » Needs work

Hi @jackwrfuller thanks for reporting this, and for working on fixing it. I think that maybe we should include a backwards compatibility layer as per the guidance in the change record https://www.drupal.org/node/3375748. Either that, or we should update the module's info file to indicate that it requires Drupal core 10.2.0+. What do you think? Is this something you can work on? If not, I can jump in and help out.

jackwrfuller’s picture

Status: Needs work » Needs review

@eojthebrave it doesn't seem like much extra work to add the BC layer, so I added it.

eojthebrave’s picture

Status: Needs review » Fixed

Thank you. I'll get this merged and create a new release ASAP.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.