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
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | incorrect-section-serialization-issue-0.patch | 794 bytes | nehajyoti |
Comments
Comment #2
jaykandariComment #3
jaykandariOn initial investigation found that the
Sectionobject is not correctly setting and instead_PHP_Incomplete_Class(Drupal\layout_builder\Section)is being set.Comment #4
larowlanThis is likely a difference in the serialise function between PHP versions, ie the serialised value can no longer be unserialised
Comment #5
cilefen commentedI agree that makes sense but I don't know of any documented serialization format breaks in 8.0.
Comment #8
nehajyoti commentedLatest patch to fix issue occuring while drupal core upgrade from 10.3.* to 10.4.3