Object support when dumping a YAML file has been disabled

Created on 6 July 2024, 6 months ago
Updated 5 August 2024, 5 months ago

Problem/Motivation

Created a simple model to send all referenced entities from a content reference field to a token, but get the following error upon execution:

Drupal\Core\Entity\EntityStorageException: Object support when dumping a YAML file has been disabled. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Drupal core = 10.4.0-dev
ECA = 2.0

This has worked for me in the past, but just recently noticed it failing on a new model I created, possibly since upgrading to 2.0?

Steps to reproduce

Save entity to trigger ECA action "pre-save content entity" (model attached)

Log with Backtrace:
The website encountered an unexpected error. Try again later.

Drupal\Core\Entity\EntityStorageException: Object support when dumping a YAML file has been disabled. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Symfony\Component\Yaml\Dumper->dump() (Line: 133)
Symfony\Component\Yaml\Dumper->dump() (Line: 133)
Symfony\Component\Yaml\Dumper->dump() (Line: 133)
Symfony\Component\Yaml\Dumper->dump() (Line: 133)
Symfony\Component\Yaml\Dumper->dump() (Line: 22)
Drupal\Component\Serialization\Yaml::encode() (Line: 411)
Drupal\eca\Plugin\DataType\DataTransferObject->getString() (Line: 418)
Drupal\eca\Plugin\DataType\DataTransferObject->__toString() (Line: 171)
eca_tokens()
call_user_func_array() (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 423)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 364)
Drupal\Core\Utility\Token->generate() (Line: 392)
Drupal\eca\Token\ContribToken->generate() (Line: 241)
Drupal\Core\Utility\Token->doReplace() (Line: 191)
Drupal\Core\Utility\Token->replace() (Line: 403)
Drupal\eca\Token\ContribToken->replace() (Line: 142)
Drupal\eca\Token\TokenServices->replace() (Line: 150)
Drupal\eca\Token\TokenServices->replaceClear() (Line: 81)
Drupal\eca\Entity\Objects\EcaAction::Drupal\eca\Entity\Objects\{closure}()
array_walk_recursive() (Line: 83)
Drupal\eca\Entity\Objects\EcaAction->execute() (Line: 290)
Drupal\eca\Processor->executeSuccessors() (Line: 292)
Drupal\eca\Processor->executeSuccessors() (Line: 221)
Drupal\eca\Processor->execute() (Line: 39)
Drupal\eca\EventSubscriber\DynamicSubscriber->onEvent()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 66)
Drupal\eca\Event\TriggerEvent->dispatchFromPlugin() (Line: 199)
Drupal\eca_content\HookHandler->presave() (Line: 83)
eca_content_entity_presave()
call_user_func_array() (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}() (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 423)
Drupal\Core\Extension\ModuleHandler->invokeAll() (Line: 217)
Drupal\Core\Entity\EntityStorageBase->invokeHook() (Line: 900)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook() (Line: 529)
Drupal\Core\Entity\EntityStorageBase->doPreSave() (Line: 753)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave() (Line: 483)
Drupal\Core\Entity\EntityStorageBase->save() (Line: 806)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Line: 357)
Drupal\Core\Entity\EntityBase->save() (Line: 293)
Drupal\Core\Entity\EntityForm->save() (Line: 125)
Drupal\storage\Form\StorageForm->save()
call_user_func_array() (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm() (Line: 601)
Drupal\Core\Form\FormBuilder->processForm() (Line: 330)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

πŸ’¬ Support request
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eswiderski

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

Comments & Activities

  • Issue created by @eswiderski
  • πŸ‡ΊπŸ‡ΈUnited States eswiderski
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This is caused by the usage of the message list-related = [list-related] which has to Yaml-encode the complex content of the list-related token into a string. As this token contains objects that can't be encoded, this exception is being thrown.

    The Yaml encoder comes from Drupal core which uses the Yaml dumper from Symfony. I am not sure if and what they changed in that regard, but serializing a list of entity references is probably something that can and should be avoided.

  • πŸ‡ΊπŸ‡ΈUnited States eswiderski

    Thanks @jurgenhaas.

    Do you have a better suggestion to simply store a list of entity ID's from a reference field (to enable a loop action on each of the referenced entities)?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Do you need to store them? The problem is not about storing them but the fact that the message needs them as a string, when you want to display the list.

    If you take the list and then loop over that list, without displaying the list on screen, then you should be fine already, aren't you?

  • Status changed to Postponed: needs info 5 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • πŸ‡©πŸ‡ͺGermany mxh Offenburg

    For me this is a bug, since the error may come from user configuration as shown here. The DTO implementation obviously does not properly cover the conversion of typed data objects into strings when requested. This should be fixed within the DTO implementation.

  • πŸ‡ΊπŸ‡ΈUnited States eswiderski

    @mxh This also feels like a bug to me, given it only occurs with Storage entities (action = Presave Content Entity Type -> Storage). If I create a similar process based on action Presave Content Entity with type Content, no error appears for me.

    @jurgenhaas Confirmed, I'm not storing them, so looping through them on my process does work. I mainly just wanted to display it for debugging it.

    This is certainly not critical and my process works, so should probably be very low priority.

    Thank you!

Production build 0.71.5 2024