Problem/Motivation

After recent PHP 7.4 to 8 upgrade and core update from 9.3.12 to 9.4.6. Facing an issue with layout builder.
WSOD after rebuilding the cache.

Below is a whole stack trace of the error:

The website encountered an unexpected error. Please try again later.

InvalidArgumentException: Value assigned to "section" is not a valid section in Drupal\layout_builder\Plugin\DataType\SectionData->setValue() (line 38 of core/modules/layout_builder/src/Plugin/DataType/SectionData.php).
Drupal\Core\TypedData\TypedDataManager->getPropertyInstance(Object, 'section', Object) (Line: 120)
Drupal\Core\TypedData\Plugin\DataType\Map->get('section') (Line: 164)
Drupal\Core\TypedData\Plugin\DataType\Map->getProperties() (Line: 50)
Drupal\layout_builder\Plugin\Field\FieldType\LayoutSectionItem->__get('section') (Line: 38)
Drupal\layout_builder\Field\LayoutSectionItemList->getSections() (Line: 50)
Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase->getSections() (Line: 403)
Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage->isOverridden() (Line: 393)
Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage->isApplicable(Object) (Line: 96)
Drupal\layout_builder\SectionStorage\SectionStorageManager->findByContext(Array, Object) (Line: 311)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildSections(Object) (Line: 275)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 340)
Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 24)
Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 282)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func_array(Array, Array) (Line: 101)
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: 772)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 363)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 201)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
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: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 164)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 56)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

* Rebuild cache (drush cr)
* View any page containing layout builder configured. (issue occurs for both admin/non admin users)
Note: This issue doesn't occur on next page load.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

JayKandari created an issue. See original summary.

jaykandari’s picture

Issue summary: View changes
jaykandari’s picture

On initial investigation found that the Section object is not correctly setting and instead _PHP_Incomplete_Class(Drupal\layout_builder\Section) is being set.

larowlan’s picture

This is likely a difference in the serialise function between PHP versions, ie the serialised value can no longer be unserialised

cilefen’s picture

I agree that makes sense but I don't know of any documented serialization format breaks in 8.0.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nehajyoti’s picture

StatusFileSize
new794 bytes

Latest patch to fix issue occuring while drupal core upgrade from 10.3.* to 10.4.3

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.