LogicException: Cannot create key "loading"

Created on 28 January 2025, 7 months ago

Problem

LogicException: Cannot create key "loading" on non-array value. in Drupal\Component\Utility\NestedArray::setValue() (line 154 of /code/web/core/lib/Drupal/Component/Utility/NestedArray.php).

This issue occured on PHP 8.3

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇮🇳India Jeya sundhar Coimbatore

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

Merge Requests

Comments & Activities

  • Issue created by @Jeya sundhar
  • Pipeline finished with Success
    7 months ago
    Total: 410s
    #408139
  • 🇮🇩Indonesia gausarts

    Thank you.

    I am using PHP8.3, as well, and see no evils.

    I'd love to see a repro.

    Also paste the entire error message so we can trace the caller aka the bad boy.

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

  • First commit to issue fork.
  • 🇸🇰Slovakia trafo

    In my case symptoms were that BlazySettings::$storage['image'] was set to false. So when in Check::uiContainer() is image.loading set, you get "LogicException", because image is not an array.

    The issue was that I did not have image locally. In BlazyResponsiveImage::dimensions() is expected that in the end $dimensions is not empty and overrides image. But if you don't have dimensions end($dimensions) returns FALSE and you end up with $blazies->set('image', FALSE, TRUE);.

  • Pipeline finished with Success
    5 months ago
    Total: 257s
    #458092
  • 🇮🇩Indonesia gausarts

    @trafo, thank you.

    Please describe a reproduction.

    Bugs must have a consistent reproduction. Without one, it might be glitches, personal overrides, and many other reasons, which may or may not be valid. Only reproduction can validate it.

    Feel free to re-open or create a new thread.

  • Status changed to Fixed 24 days ago
  • I'd like to mention I just ran into this issue as well.

    Given this is an existing codebase I'm tasked to work on, I cannot say for sure how to faithfully reproduce it. As far as I can see, the image display settings are all default but loading priority is set to 'lazy'.

    Applying sundhar's patch fixes the exception for me.

    I've attached the full stack trace below:

    LogicException: Cannot create key "loading" on non-array value. in Drupal\Component\Utility\NestedArray::setValue() (line 154 of core/lib/Drupal/Component/Utility/NestedArray.php).
    
    Drupal\blazy\BlazySettings->setInternal('image.loading', 'lazy', 1) (Line: 215)
    Drupal\blazy\BlazySettings->set('image.loading', 'lazy') (Line: 102)
    Drupal\blazy\Utility\Check::uiContainer(Array) (Line: 35)
    Drupal\blazy\Utility\Check::container(Array) (Line: 230)
    Drupal\blazy\internals\Settings::preSettings(Array) (Line: 231)
    Drupal\blazy\BlazyManagerBase->preSettings(Array) (Line: 175)
    Drupal\blazy\Utility\Check::blazyOrNot(Array, Array) (Line: 115)
    Drupal\blazy\BlazyManagerBase->isBlazy(Array, Array) (Line: 394)
    Drupal\blazy\BlazyManager->getBlazySettings(Array) (Line: 121)
    Drupal\blazy\BlazyManager->build(Array) (Line: 73)
    Drupal\blazy\Plugin\Field\FieldFormatter\BlazyFileFormatterBase->commonViewElements(Object, 'nl', Array) (Line: 153)
    Drupal\blazy\Plugin\Field\FieldFormatter\BlazyFileFormatterBase->viewElements(Object, 'nl') (Line: 91)
    Drupal\Core\Field\FormatterBase->view(Object, 'nl') (Line: 83)
    Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view(Object, NULL) (Line: 268)
    Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 340)
    Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full_width') (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: 886)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 431)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 390)
    Drupal\media\Plugin\Filter\MediaEmbed->Drupal\media\Plugin\Filter\{closure}() (Line: 637)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 389)
    Drupal\media\Plugin\Filter\MediaEmbed->renderIntoDomNode(Array, Object, Object) (Line: 342)
    Drupal\media\Plugin\Filter\MediaEmbed->process('<redacted>', 'nl') (Line: 123)
    Drupal\filter\Element\ProcessedText::preRenderText(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: 886)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 431)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 484)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 93)
    __TwigTemplate_9343c567e7ac14335615738349925853->doDisplay(Array, Array) (Line: 388)
    Twig\Template->yield(Array, Array) (Line: 51)
    __TwigTemplate_e5c488a8015c8ce3bb1ccb022eacab6e->doDisplay(Array, Array) (Line: 388)
    Twig\Template->yield(Array, Array) (Line: 48)
    __TwigTemplate_e0f39a5c8adf99d41d7ef49806ce3f4a->doDisplay(Array, Array) (Line: 388)
    Twig\Template->yield(Array, Array) (Line: 344)
    Twig\Template->display(Array) (Line: 359)
    Twig\Template->render(Array) (Line: 51)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/contrib/classy/templates/field/field--text-long.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 490)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 503)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 484)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 88)
    __TwigTemplate_ea08d5d159e82daeca7a3d5e3054bd53->block_content(Array, Array) (Line: 432)
    Twig\Template->yieldBlock('content', Array, Array) (Line: 72)
    __TwigTemplate_ea08d5d159e82daeca7a3d5e3054bd53->block_paragraph(Array, Array) (Line: 432)
    Twig\Template->yieldBlock('paragraph', Array, Array) (Line: 51)
    __TwigTemplate_ea08d5d159e82daeca7a3d5e3054bd53->doDisplay(Array, Array) (Line: 388)
    Twig\Template->yield(Array, Array) (Line: 344)
    Twig\Template->display(Array) (Line: 359)
    Twig\Template->render(Array) (Line: 51)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/custom/<redacted>/templates/paragraph/paragraph.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('paragraph', Array) (Line: 490)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 484)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 73)
    __TwigTemplate_9343c567e7ac14335615738349925853->doDisplay(Array, Array) (Line: 388)
    Twig\Template->yield(Array, Array) (Line: 344)
    Twig\Template->display(Array) (Line: 359)
    Twig\Template->render(Array) (Line: 51)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/contrib/classy/templates/field/field.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 490)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 484)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 249)
    __TwigTemplate_149c6f631f42430abc1d8e83e77870d7->doDisplay(Array, Array) (Line: 388)
    Twig\Template->yield(Array, Array) (Line: 344)
    Twig\Template->display(Array) (Line: 359)
    Twig\Template->render(Array) (Line: 51)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/custom/<redacted>/templates/node/node--article--full.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('node', Array) (Line: 490)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 637)
    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)
    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: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 55)
    Drupal\crawler_rate_limit\CrawlerRateLimitMiddleware->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