Problem/Motivation

Smart Date with Duration in Layout builder causes endless loop

Steps to reproduce

  • On a fresh copy of Drupal 9.1.7 install and enable Smart Date Starter Kit and Layout Builder
  • Go to the display configuration for the Event content type and enable layout builder
  • Click Manage layout to enter Layout Builder
  • It is not necessary to make any layout changes, but it seems to work fine if you do
  • Configure the "When" field and change the formatter to Smart Date with Duration, and observe that it successfully generates a sample value
  • Click Save layout at the top and observe that it generates the following error:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /Users/martin/Sites/drupal9/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php on line 174

I will add that I tried to use devel_debug_log to output the contents of $this->cacheKey in DefaultPluginManager.php just before line 174, and then got an error that devel_debug_log had run out of memory.

As mentioned in a comment, using Layout Builder with the default formatter appears to work as expected.

Original post included the following details:
Setting the Formatter to "Smarte Date with Duration" and Comact or default Date Format gives:

Error: Maximum function nesting level of '1024' reached, aborting! in Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (line 172 of /../html/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php)

#0 /../html/core/lib/Drupal/Core/Config/TypedConfigManager.php(160): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
#1 /../html/core/lib/Drupal/Core/Config/TypedConfigManager.php(200): Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements()
#2 /../html/core/lib/Drupal/Core/Config/TypedConfigManager.php(165): Drupal\Core\Config\TypedConfigManager->getDefinition()
#3 /../html/core/lib/Drupal/Core/Config/TypedConfigManager.php(200): Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements()
#4 /../html/core/lib/Drupal/Core/Config/TypedConfigManager.php(165): Drupal\Core\Config\TypedConfigManager->getDefinition()
#5 /../html/core/lib/Drupal/Core/Config/TypedConfigManager.php(200): Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements()
#6 /../html/core/lib/Drupal/Core/Config/TypedConfigManager.php(165): Drupal\Core\Config\TypedConfigManager->getDefinition()

...

/../html/core/lib/Drupal/Core/Config/TypedConfigManager.php(105): Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements()
#978 /../html/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(153): Drupal\Core\Config\TypedConfigManager->buildDataDefinition()
#979 /../html/core/lib/Drupal/Core/Config/Schema/Mapping.php(26): Drupal\Core\Config\Schema\ArrayElement->buildDataDefinition()
#980 /../html/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(37): Drupal\Core\Config\Schema\Mapping->getElementDefinition()
#981 /../html/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(85): Drupal\Core\Config\Schema\ArrayElement->parse()
#982 /../html/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(59): Drupal\Core\Config\Schema\ArrayElement->getElements()
#983 /../html/core/lib/Drupal/Core/Config/Schema/ArrayElement.php(65): Drupal\Core\Config\Schema\ArrayElement->get()
#984 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(179): Drupal\Core\Config\Schema\ArrayElement->get()
#985 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(211): Drupal\Core\Config\StorableConfigBase->castValue()
#986 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(211): Drupal\Core\Config\StorableConfigBase->castValue()
#987 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(211): Drupal\Core\Config\StorableConfigBase->castValue()
#988 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(211): Drupal\Core\Config\StorableConfigBase->castValue()
#989 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(211): Drupal\Core\Config\StorableConfigBase->castValue()
#990 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(211): Drupal\Core\Config\StorableConfigBase->castValue()
#991 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(211): Drupal\Core\Config\StorableConfigBase->castValue()
#992 /../html/core/lib/Drupal/Core/Config/StorableConfigBase.php(211): Drupal\Core\Config\StorableConfigBase->castValue()
#993 /../html/core/lib/Drupal/Core/Config/Config.php(212): Drupal\Core\Config\StorableConfigBase->castValue()
#994 /../html/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(284): Drupal\Core\Config\Config->save()
#995 /../html/core/lib/Drupal/Core/Entity/EntityStorageBase.php(452): Drupal\Core\Config\Entity\ConfigEntityStorage->doSave()
#996 /../html/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(263): Drupal\Core\Entity\EntityStorageBase->save()
#997 /../html/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Config\Entity\ConfigEntityStorage->save()
#998 /../html/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(591): Drupal\Core\Entity\EntityBase->save()
#999 /../html/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php(300): Drupal\Core\Config\Entity\ConfigEntityBase->save()
#1000 /../html/core/modules/layout_builder/src/Form/DefaultsEntityForm.php(200): Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->save()
#1001 [internal function]: Drupal\layout_builder\Form\DefaultsEntityForm->save()
#1002 /../html/core/lib/Drupal/Core/Form/FormSubmitter.php(113): call_user_func_array()
#1003 /../html/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
#1004 /../html/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormSubmitter->doSubmitForm()
#1005 /../html/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm()
#1006 /../html/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#1007 /../html/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
#1008 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#1009 /../html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#1010 /../html/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#1011 /../html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#1012 /../html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#1013 /../html/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#1014 /../html/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#1015 /../html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle()
#1016 /../html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle()
#1017 /../html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#1018 /../html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#1019 /../html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle()
#1020 /../html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#1021 /../html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#1022 /../html/core/lib/Drupal/Core/DrupalKernel.php(706): Stack\StackedHttpKernel->handle()
#1023 /../html/index.php(19): Drupal\Core\DrupalKernel->handle()
#1024 {main}

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
2021-04-27_12h51_12.png10.94 KBmaxilein

Comments

maxilein created an issue. See original summary.

maxilein’s picture

Forgot to mention: D 9.1.7

Smart Date Formatter does work.

Smart Date based on an standard Drupal date range field.

maxilein’s picture

Title: Smart Date with duration in Layout builder causes endless loop » Smart Date with Duration in Layout builder causes endless loop
Issue summary: View changes
mandclu’s picture

Issue summary: View changes
mandclu’s picture

Issue summary: View changes
mandclu’s picture

Issue summary: View changes
mandclu’s picture

Issue summary: View changes

  • mandclu committed 6fed8d4 on 3.4.x
    Issue #3210905 by mandclu: Smart Date with Duration in Layout builder...
mandclu’s picture

Status: Active » Fixed

After merging in #3221364: Out of memory error when using Duration formatter I encountered some errors about private functions, so moved a number of previously private functions to protected. After doing this, the duration formatter appears to work fine with Layout Builder. Merged in these changes and marking this as fixed, but feel free to re-open if you encounter any other errors.

Status: Fixed » Closed (fixed)

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