Entity Slideshow causes Layout Builder Timestamp error (after upgrade to 9.3.12)

Created on 29 April 2022, over 2 years ago
Updated 9 May 2024, 5 months ago

Problem

I am developing a website, just upgraded to core 9.3.12. Upgrade went well (composer), but after the upgrade I suddenly had an issue with Layout Builder.

In all Layout Builder enabled content types that existed before the upgrade I could now no longer edit the template for all 'foo' content type items. I can still edit the individual existing pages across different content types, just not the overall default template for each type.

When selecting "Edit the template for all Basic page content items instead" at top of a page layout, or when going through "structure> Content Types > Foo > Manage Display >> Manage Layout (Default or Full or other any existing one), I get a WSOD saying "The website encountered an unexpected error. Please try again later."

So I checked the error log, which tells me: "Uncaught PHP Exception InvalidArgumentException: "The timestamp must be numeric." at /.../core/lib/Drupal/Component/Datetime/DateTimePlus.php line 201". When I create a new content type and enable Layout Builder, all works fine, I can then edit individual pages as well as the content type template.

Switched on the level error messages, got the following stack, indicating Media entity slideshow was at the root of the error:

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

InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 201 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).
Drupal\Core\Datetime\DateFormatter->format(NULL, 'custom', 'Y-m-d\TH:i:s') (Line: 50)
Drupal\media_entity_slideshow\Plugin\media\Source\Slideshow->getMetadata(Object, 'default_name') (Line: 99)
Drupal\media\Entity\Media->getName() (Line: 109)
Drupal\media\Entity\Media->label() (Line: 355)
Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection->getReferenceableEntities(NULL, 'CONTAINS', 50) (Line: 305)
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::generateSampleValue(Object) (Line: 253)
Drupal\Core\Field\FieldItemList->generateSampleItems() (Line: 248)
Drupal\Core\Entity\ContentEntityStorageBase->createWithSampleValues('page') (Line: 55)
Drupal\layout_builder\Entity\LayoutBuilderSampleEntityGenerator->get('node', 'page') (Line: 224)
Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->getContextsDuringPreview() (Line: 71)
Drupal\layout_builder\Element\LayoutBuilder->getPopulatedContexts(Object) (Line: 236)
Drupal\layout_builder\Element\LayoutBuilder->buildAdministrativeSection(Object, 0) (Line: 124)
Drupal\layout_builder\Element\LayoutBuilder->layout(Object) (Line: 98)
Drupal\layout_builder\Element\LayoutBuilder->preRender(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: 435)
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: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
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: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Uninstalled the module and hey presto, all Layout Builder Functionality was back in perfect working order.

In summary: before upgrading core to 9.3.12 all worked fine, after the upgrade Layout Builder on existing content types failed due to a timestamp issue triggered by Media Entity Slideshow

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom xax London, UK

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Assigned to Anybody
  • 🇩🇪Germany Anybody Porta Westfalica

    The reason is, that layout builder generates sample values, but in that case, the created value is NULL.
    I'll prepare a MR.

  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Okay, here we go. I was unsure to entirely remove the timestamp (as I did now) vs. adding ?? time() or solving it even more complicated.

    As the timestamp isn't very helpful in the default name, I decided to remove it.

    Would be nice if a maintainer could review and merge this to get the fatal error fixed!

  • @anybody opened merge request.
  • Status changed to Needs work over 1 year ago
  • 🇨🇦Canada smulvih2 Canada 🍁

    @Anybody, you should also remove the use statement for DateTimeItemInterface since it is no longer being used after your change.

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 8
    last update over 1 year ago
    2 pass
  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany Grevil

    Fixed that, no need to credit.

  • Issue was unassigned.
  • Status changed to RTBC 5 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Well done @Grevil! RTBC from my side.

    @smulvih2 ready?

  • 🇨🇦Canada smulvih2 Canada 🍁

    +1 RTBC

Production build 0.71.5 2024