DiffArray does not serialize Layout builder section objects causing an error with view display configs managed by layout_builder

Created on 6 September 2021, over 3 years ago
Updated 1 August 2024, 5 months ago

Problem/Motivation

This issue was detected when testing partial split feature. It looks like the layout builder sections on the config_split are not being serialized at this point, so they are placed in the diff as an object. if that diff is used by the config storage, it throws an exception because the validation fails:

web/core/lib/Drupal/Core/Config/StorableConfigBase.php:207

// Throw exception on any non-scalar or non-array value.
if (!is_array($value)) {
  throw new UnsupportedDataTypeConfigException("Invalid data type for config element {$this->getName()}:$key");
}

Steps to reproduce

Proposed resolution

a) Serialize the section object before placing it into the diff
b) Implement an interface into the Section object and then try to serialize any object with that interface

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ConfigurationΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ͺπŸ‡ΈSpain akalam

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

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

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Tagging for steps to reproduce this to verify if it's an issue in D10
    Tagging for tests to show this issue and that the proposed fix works

    The proposed solution doesn't seem to match the MR. Is there still more work to be done there?

    Also we will need to update the MR for Drupal 10.1.x please

    Thanks!

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

    I was looking at this and don't think I like A) or B), as a utility function I don't think DiffArray should be making changes to form of the inputs and definitely core should not be updated with a hardcoded classname. That seems like maybe normalizing data should be done in StorableConfigBase itself, since it is the one opinionated about only storing arrays. Maybe it should then attempt to do any array conversion/normalization/serialization of objects. Or maybe config_split itself needs to massage everything since it is opinionated about only working with arrays, or maybe layout_builder should make sure all of it's config-able data are arrays to begin with.

  • πŸ‡ͺπŸ‡ΈSpain unstatu

    I have researched the problem without success but I implemented a VERY HACKY AND UGLY fix for it. Just to have the configuration manager system working again.

    I let the solution here just in case is useful for someone.

  • πŸ‡ͺπŸ‡ΈSpain miguelarber

    The patch provided in #11 seems to be problematic as it throws the following error when importing the site's configuration:

    TypeError: Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage::Drupal\layout_builder\Entity\{closure}(): Argument #1 ($section) must be of type Drupal\layout_builder\Section, array given in Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplayStorage->Drupal\layout_builder\Entity\{closure}() (line 24 of /app/web/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplayStorage.php)

    Based on the previous patch, I have performed some small adjustments that should do the trick and allow you bypass the mentioned issues.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Environment: PHP 8.2 & MySQL 8 (--ignore-platfrom-reqs)
    last update about 1 year ago
    Build Successful
  • πŸ‡ͺπŸ‡ΈSpain akalam

    I found after applying patches #11 and #12 the config export is fixed but the config import started to fail. Here is a single patch combining both patches and adding a fix for the config import

  • last update about 1 year ago
    30,436 pass
  • πŸ‡ͺπŸ‡ΈSpain tonibarbera

    I've rerolled the #13 patch for Drupal 10.3.1.

Production build 0.71.5 2024