Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Issue fork config_split-3396813
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:
- 3396813-return-false-when changes, plain diff MR !40 / changes, plain diff MR !39
Comments
Comment #3
bircherSo this is a bug in Config Filter, actually.
Comment #9
bircherComment #10
bircherComment #12
bircherComment #14
jonsimonsen CreditAttribution: jonsimonsen at Ramsalt Lab commentedFor 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
Comment #15
bircherupdating the issue summary for posterity.
Comment #17
donquixote CreditAttribution: donquixote at European Commission and European Union Institutions, Agencies and Bodies commentedIt 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.
Comment #18
donquixote CreditAttribution: donquixote at European Commission and European Union Institutions, Agencies and Bodies commentedActually 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.
Comment #19
donquixote CreditAttribution: donquixote at European Commission and European Union Institutions, Agencies and Bodies commentedI wonder what would happen if, in the loop, when $data is FALSE or NULL, we call ->filterDelete() instead of ->filterWrite()?
Comment #20
bircheran 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.
Comment #21
donquixote CreditAttribution: donquixote at European Commission and European Union Institutions, Agencies and Bodies commentedYou are right!
The
$data = FALSE
only happens if it already was not an array before.So it's all good.
Sorry for the noise :)