Fatal error with _gin_gutenberg_is_gutenberg_enabled() on some views pages

Created on 28 May 2024, 29 days ago
Updated 17 June 2024, 9 days ago

Problem/Motivation

Sometimes the 'node' route parameter is a string and not an instance of EntityInterface, most notably on views with a node argument, but I guess it could occur other places.

I believe it has to do with this issue πŸ› Fix label token replacement for views entity reference arguments RTBC

In these cases I am getting an error with _gin_gutenberg_is_gutenberg_enabled()

TypeError: _gin_gutenberg_is_gutenberg_enabled(): Argument #1 ($entity) must be of type ?Drupal\Core\Entity\EntityInterface, string given, called in /web/modules/contrib/gin_gutenberg/gin_gutenberg.module on line 41 in _gin_gutenberg_is_gutenberg_enabled() (line 205 of modules/contrib/gin_gutenberg/gin_gutenberg.module).

gin_gutenberg_theme_registry_alter(Array, NULL, NULL) (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter('theme_registry', Array) (Line: 404)
Drupal\Core\Theme\Registry->build() (Line: 255)
Drupal\Core\Theme\Registry->get() (Line: 88)
Drupal\Core\Utility\ThemeRegistry->initializeRegistry() (Line: 69)
Drupal\Core\Utility\ThemeRegistry->__construct('theme_registry:runtime:gin', Object, Object, Array, 1) (Line: 291)
Drupal\Core\Theme\Registry->getRuntime() (Line: 141)
Drupal\Core\Theme\ThemeManager->render(Array, Array) (Line: 480)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array) (Line: 1790)
Drupal\views\Plugin\views\field\FieldPluginBase->theme(Object) (Line: 765)
Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow(Array)
call_user_func_array(Array, Array) (Line: 111)

Steps to reproduce

  • With this module enabled, Create a view page with the path '/node/%node/anything' as the path.
  • Go to /node/[NID]/anything with a valid NID
  • You may need to clear the cache while on this page.
  • You get this error

Proposed resolution

return false if the value is not an instance of EntityInterface in _gin_gutenberg_is_gutenberg_enabled()

πŸ› Bug report
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States loze

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024