Illegal offset type in isset or empty at ContentEntityBase.php

Created on 12 October 2024, 2 months ago

Problem/Motivation

I ran into a problem, where it was not possible to save the node-widget when using linked_field together with a link field.

Steps to reproduce

Enable linked_field for a node display and try to link to a link-field. Save the form and watch it fail.

Proposed resolution

Edit the code to test for various types of field-values. I saw a similar issue here: https://www.drupal.org/project/drupal/issues/3422662 ๐Ÿ› Illegal offset type in isset or empty" at ContentEntityBase.php ย  Active

๐Ÿ› Bug report
Status

Active

Version

1.5

Component

Code

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany dotist

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

Comments & Activities

  • Issue created by @dotist
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany dotist

    See patch.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhishek_virasat

    abhishek_gupta1 โ†’ made their first commit to this issueโ€™s fork.

  • @abhishek_gupta1 opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhishek_virasat

    @yannickoo, I have tested above path locally, fixed the issue and I created MR easy to merge. please review it once.

  • ๐Ÿ‡ฎ๐Ÿ‡ชIreland keoal

    I added the patch but receive the following error when the module is enabled, it goes away once the module is disabled:

    TypeError: Illegal offset type in Drupal\Core\Entity\ContentEntityBase->get() (line 596 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
    Drupal\linked_field\LinkedFieldManager->getDestination('field', Array, Array) (Line: 361)
    linked_field_entity_display_build_alter(Array, Array, NULL) (Line: 552)
    Drupal\Core\Extension\ModuleHandler->alter('entity_display_build', Array, Array) (Line: 289)
    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)
    call_user_func(Array, Object, 'section_component.build.render_array', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'section_component.build.render_array') (Line: 90)
    Drupal\layout_builder\SectionComponent->toRenderArray(Array, ) (Line: 88)
    Drupal\layout_builder\Section->toRenderArray(Array) (Line: 331)
    Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildSections(Object) (Line: 291)
    Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 340)
    Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'ergebnisse_anrisstext') (Line: 24)
    Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'ergebnisse_anrisstext') (Line: 282)
    Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
    Drupal\Core\Entity\EntityViewBuilder->build(Array)
    call_user_func_array(Array, Array) (Line: 113)
    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: 870)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 432)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 476)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 66)
    __TwigTemplate_a637f967736943ae7f237fd8018de925->doDisplay(Array, Array) (Line: 393)
    Twig\Template->yield(Array, Array) (Line: 349)
    Twig\Template->display(Array) (Line: 364)
    Twig\Template->render(Array) (Line: 35)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/contrib/bootstrap_barrio/templates/views/views-view-unformatted.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('views_view_unformatted', Array) (Line: 491)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 476)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 115)
    __TwigTemplate_d094ece2a91c0ef6baaf1df1d2f87e48->doDisplay(Array, Array) (Line: 393)
    Twig\Template->yield(Array, Array) (Line: 349)
    Twig\Template->display(Array) (Line: 364)
    Twig\Template->render(Array) (Line: 35)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/contrib/bootstrap_barrio/templates/views/views-view.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('views_view', Array) (Line: 491)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 476)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 94)
    __TwigTemplate_f387d4448419eb25fade8c0d8bab31e6->block_content(Array, Array) (Line: 437)
    Twig\Template->yieldBlock('content', Array, Array) (Line: 73)
    __TwigTemplate_f387d4448419eb25fade8c0d8bab31e6->doDisplay(Array, Array) (Line: 393)
    Twig\Template->yield(Array, Array) (Line: 349)
    Twig\Template->display(Array) (Line: 364)
    Twig\Template->render(Array) (Line: 35)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/contrib/bootstrap_barrio/templates/block/block.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 491)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 476)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 198)
    __TwigTemplate_815024a4400c3c702ee77437a7e36299->block_content(Array, Array) (Line: 437)
    Twig\Template->yieldBlock('content', Array, Array) (Line: 94)
    __TwigTemplate_af47064ab0f145c76899a71cfdbb5db8->doDisplay(Array, Array) (Line: 393)
    Twig\Template->yield(Array, Array) (Line: 57)
    __TwigTemplate_815024a4400c3c702ee77437a7e36299->doDisplay(Array, Array) (Line: 393)
    Twig\Template->yield(Array, Array) (Line: 349)
    Twig\Template->display(Array) (Line: 364)
    Twig\Template->render(Array) (Line: 35)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/custom/zirtenet_barrio/templates/page.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 491)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 476)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 91)
    __TwigTemplate_35ce047127c575d07909a37f705ed738->doDisplay(Array, Array) (Line: 393)
    Twig\Template->yield(Array, Array) (Line: 349)
    Twig\Template->display(Array) (Line: 364)
    Twig\Template->render(Array) (Line: 35)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/custom/zirtenet_barrio/templates/layout/html.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 491)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 158)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 153)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
    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: 191)
    Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 128)
    Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 82)
    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: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Production build 0.71.5 2024