While working with this module and Config_filter I noted that the config storage provided by this module was removing some empty arrays which were expected to exists.

For instance, consider this fragment of configuration:

[id] => node.win.teaser
    [targetEntityType] => node
    [bundle] => win
    [mode] => teaser
    [content] => Array
        (
            [body] => Array
                (
                    [type] => smart_trim
                    [weight] => 4
                    [region] => ds_content
                    [label] => visually_hidden
                    [settings] => Array
                        (
                            [trim_length] => 150
                            [trim_type] => chars
                            [trim_suffix] => ...
                            [wrap_class] => trimmed
                            [more_link] => 1
                            [more_text] => More »
                            [more_class] => card-more-link
                            [summary_handler] => full
                            [trim_options] => Array
                                (
                                    [text] => 1
                                    [trim_zero] =>
                                )

                            [wrap_output] =>
                        )

                    [third_party_settings] => Array
                        (
                        )

                )

The third_party_settings is an empty array and therefore is deleted when this module process the storage but this key is expected by any formatter plugin (see FormatterBase.php):

public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings) {
    parent::__construct([], $plugin_id, $plugin_definition);

    $this->fieldDefinition = $field_definition;
    $this->settings = $settings;
    $this->label = $label;
    $this->viewMode = $view_mode;
    $this->thirdPartySettings = $third_party_settings;
  }

So, delete empty arrays could break the integrity of the configuration.

What needs to be done is remove the line which delete the empty arrays in InMemoryStorage::normalizeArray().

CommentFileSizeAuthor
#2 3001073.patch385 bytesgnuget

Comments

gnuget created an issue. See original summary.

gnuget’s picture

StatusFileSize
new385 bytes

Patch attached.

gnuget’s picture

Issue summary: View changes
nedjo’s picture

Status: Active » Reviewed & tested by the community

That sounds right. Please go ahead and commit this.

We forked the normalize method from Configuration Update Manager. #2962529: Figure out normalization for ConfigDiffer is related in that it also identifies potential problems with removing empty arrays.

#2994128: Enable optional normalization on read from storage is a suggestion to move this code to Configuration Update Manager where it can be reused by other modules. But meantime, if we remove this here, we should also do so in the other place we've forked this code: Configuration Snapshot's ConfigSnapshotStorage::normalizeArray() method. So I've opened #3001243: normalizeArray shouldn't remove empty arrays.

mlncn’s picture

Status: Reviewed & tested by the community » Fixed

Excellent!

  • mlncn committed ef4c84e on 8.x-2.x authored by gnuget
    Issue #3001073 by gnuget, nedjo: normalizeArray shouldn't remove empty...

Status: Fixed » Closed (fixed)

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