Problem/Motivation

When trying to export a node with a Layout Builder layout we encounter following exception:

Drupal\Component\Serialization\Exception\InvalidDataTypeException: Object support when dumping a YAML file has been disabled. in Drupal\Component\Serialization\Yaml::encode() (line 25 of core/lib/Drupal/Component/Serialization/Yaml.php).

This happens because the configuration of the components have a TranslatableMarkup object as label.

Steps to reproduce

  • Enable Layout Builder
  • Configure a node layout with some inline blocks (note: we don't show the label field)
  • Try to export the node
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

matthijs created an issue. See original summary.

matthijs’s picture

Status: Active » Needs review
nginex’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for this, I also noticed that issue after switching out from base64 string approach. This is caused by RS mainly, anyway, good to see it's fixed

dieuwe’s picture

I've encountered other TranslatableMarkup issues with LB, in particular slots plugins from single directory components. There will be a lot more of this as it seems greater translation support is an active innitiatve: #3044386: [META] Make Layout Builder layouts translatable.

Not sure what the idea solution is here - recursively loop through components and convert any translatable markup to text before exporting? Or a different approach entirely?

Adding in edge-case handling as the current issue fork does seems like a losing battle.

dieuwe’s picture

Status: Reviewed & tested by the community » Needs review

I've pushed up a change to the MR that should handle all values in LB section configuration in a way that's future-proof as more LB configuration becomes translatable.

  • nginex committed 03d1fe3a on 1.4.x authored by matthijs
    Issue #3549718: Enforce all component labels to strings
    
nginex’s picture

Status: Needs review » Fixed

This is now available in new release 1.4.14

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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