Layout Builder crashing in D11 when using Fivestar field in content type

Created on 27 September 2024, 3 months ago

Problem/Motivation

Using Drupal 11.0.2. Created new field in "Content Type" for Fivestar-3.0.x-dev and configured using default settings.
When I go into "Manage Display" and then click on"Manage Layout" (it uses Layout Builder), I get the error message above (with logging enabled in settings.php)

The website encountered an unexpected error. Try again later.

TypeError: Drupal\votingapi\VoteResultFunctionManager::getResults(): Argument #2 ($entity_id) must be of type int, null given, called in /public_html/modules/fivestar/src/VoteResultManager.php on line 55 in Drupal\votingapi\VoteResultFunctionManager->getResults() (line 86 of modules/votingapi/src/VoteResultFunctionManager.php).
Drupal\fivestar\VoteResultManager->getResults(Object) (Line: 39)
Drupal\fivestar\VoteResultManager->getResultsByVoteType(Object, 'vote') (Line: 74)
Drupal\fivestar\Form\FivestarForm->buildForm(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 528)
Drupal\Core\Form\FormBuilder->retrieveForm('fivestar_form_1', Object) (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm('Drupal\fivestar\Form\FivestarForm', Object) (Line: 219)
Drupal\Core\Form\FormBuilder->getForm('Drupal\fivestar\Form\FivestarForm', Array) (Line: 156)
Drupal\fivestar\Plugin\Field\FieldFormatter\StarsFormatter->viewElements(Object, 'en') (Line: 91)
Drupal\Core\Field\FormatterBase->view(Object, 'en') (Line: 268)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 282)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 226)
Drupal\Core\Entity\Entity\EntityViewDisplay->build(Object) (Line: 461)
Drupal\Core\Entity\EntityViewBuilder->viewField(Object, Array) (Line: 243)
Drupal\Core\Field\FieldItemList->view(Array) (Line: 167)
Drupal\layout_builder\Plugin\Block\FieldBlock->build() (Line: 106)
Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender(Object, 'section_component.build.render_array', Object) (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'section_component.build.render_array', Object) (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object, 'section_component.build.render_array') (Line: 90)
Drupal\layout_builder\SectionComponent->toRenderArray(Array, 1) (Line: 88)
Drupal\layout_builder\Section->toRenderArray(Array, 1) (Line: 228)
Drupal\layout_builder\Element\LayoutBuilder->buildAdministrativeSection(Object, 0) (Line: 112)
Drupal\layout_builder\Element\LayoutBuilder->layout(Object) (Line: 86)
Drupal\layout_builder\Element\LayoutBuilder->preRender(Array)
call_user_func_array(Array, Array) (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 825)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 387)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 459)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 203)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}(Object, 'kernel.view', Object) (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'kernel.view', Object) (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object, 'kernel.view') (Line: 188)
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)

Steps to reproduce

Created new field in "Content Type" for Fivestar-3.0.x-dev and configured using default settings.
When I go into "Manage Display" and then click on"Manage Layout" (it uses Layout Builder), I get the error message above (with logging enabled in settings.php).

Proposed resolution

Unsure. Have deleted the Field I created and now I can get into "Manage Layout".

Appreciate any feedback or if someone can further investigate. Sincere thanks :-)

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇮🇪Ireland rosscullen

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

Comments & Activities

  • Issue created by @rosscullen
  • 🇺🇸United States tr Cascadia

    Well first, note the 3.0.x version doesn't have a release yet because there are still some things that need to be properly ported to D11.

    Seems like this might have the same cause as 💬 Fivestar widget not displayed when using Layout Builder Active ?

    It sounds like using a default value for the Fivestar field might avoid the issue?

    With D11 and stricter typing, this could show up as Layout Builder generating the above type error instead of just ignoring the Fivestar field like described in that other issue.

    This could use a test case to demonstrate the problem - that way we have something concrete to prove any eventual fix works to correct the problem. And a test would help keep things working even as we make changes here and even as Layout Builder makes changes.

    I don't use Layout Builder personally, so this is going to need some help from the community to investigate and fix.

  • Status changed to Postponed: needs info 27 days ago
  • 🇺🇸United States tr Cascadia
Production build 0.71.5 2024