Problem/Motivation

We added a check for is_array to write data. But when a filter (like config split) removes a config a subsequent filter that doesn't do anything will result the data being an empty array.

Proposed resolution

Set the filtered value back to FALSE when having to pass empty data to the filerWrite method.

Remaining tasks

commit

User interface changes

none

API changes

none

Data model changes

none

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bircher created an issue. See original summary.

ayush.khare made their first commit to this issue’s fork.

bircher’s picture

Title: Return FALSE when a config should be removed in filterWrite » Use FALSE when filters return the empty array in filterWrite
Project: Configuration Split » Config Filter

So this is a bug in Config Filter, actually.

  • bircher committed e24bbab8 on 8.x-1.x
    Issue #3396813 by bircher: Use FALSE when filters return the empty array...

  • bircher committed dbd761b1 on 8.x-2.x
    Issue #3396813 by bircher: Use FALSE when filters return the empty array...
bircher’s picture

Status: Active » Fixed
bircher’s picture

Status: Fixed » Active

bircher’s picture

Status: Active » Fixed

jonsimonsen’s picture

For the record, I tested this fix on my local setup. The previous behavior of exporting empty files that should not get exported into the default sync directory (because they were in a dev split) did indeed get fixed. Thank you, Bircher

bircher’s picture

Issue summary: View changes

updating the issue summary for posterity.

Status: Fixed » Closed (fixed)

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

donquixote’s picture

It works, thank you!

I was wondering, will this not also nuke legitimate empty-array configs.
I came to the conclusion this cannot happen because all the configs contain at least the ['_core']['default_config_hash'] or a ['uuid'].
Or not?
Also in general this is not how config is used.

donquixote’s picture

Actually not so sure anymore.
If I delete all files in config/sync/* and run drush cex again, then at that point the $data['uuid'] and $data['_core']['default_config_hash'] are both missing when the data goes to ->filterWrite().

In theory, there could be a module where an empty array config has a distinct meaning that is different from a NULL config.

donquixote’s picture

I wonder what would happen if, in the loop, when $data is FALSE or NULL, we call ->filterDelete() instead of ->filterWrite()?

bircher’s picture

an empty array will remain an empty array.
The if clause checks for is_array which the empty one passes so it will not be set to false.

The only thing you can not do any more is know if a previous filter had set it to false or an empty array. But I consider that an acceptable tradeoff as it is such an edge case.

Also I think it is important to call the filter methods corresponding to the storage method and not mix them that would mean a filter behaves differently depending on other filters that come before.

donquixote’s picture

The only thing you can not do any more is know if a previous filter had set it to false or an empty array. But I consider that an acceptable tradeoff as it is such an edge case.

You are right!
The $data = FALSE only happens if it already was not an array before.
So it's all good.
Sorry for the noise :)