Call to a member function toRenderArray()

Created on 31 January 2025, 2 months ago

Getting below issue some time. But after cache clear it is working.
Any idea ?

Call to a member function toRenderArray() on array in Drupal\page_manager\Plugin\DisplayVariant\LayoutBuilderDisplayVariant->build() (line 42 of /var/www/html/docroot/modules/contrib/page_manager/src/Plugin/DisplayVariant/LayoutBuilderDisplayVariant.php).

🐛 Bug report
Status

Needs review

Component

Code

Created by

🇮🇳India arif.zisu Kolkata

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

Comments & Activities

  • Issue created by @arif.zisu
  • 🇵🇱Poland robert.kandzia

    @arif.zisu Can you share a full backtrace for the above error?

  • 🇵🇱Poland robert.kandzia

    When an error occurs, the getSections() method returns an array containing arrays.

    In my case, the getSections() method should return an array of objects of the Drupal\layout_builder\Section type. That's why the toRenderArray() method is missing.

    In the code, I found a place where the array with arrays is replaced with an array with the Section object.

    It is located in the src/Entity/LayoutBuilderStorage.php file in the mapFromStorageRecords() method.

    $sections = array_map([Section::class, 'fromArray'], $sections);
    

    But I haven't found a reason yet why it sometimes doesn't change. I suspect the cache.

    I prepared a patch to force reprocessing into arrays of objects.

Production build 0.71.5 2024