Closed (fixed)
Project:
Config Ignore
Version:
8.x-3.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
4 Mar 2020 at 12:58 UTC
Updated:
17 Aug 2021 at 23:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
ayalon commentedComment #3
claudiu.cristeaCould you, please, add more details about your case? Steps to reproduce, etc. The actual description is too generic.
Comment #4
jeroentI'm having the same problem.
On config export, the config is ignored, but on config import, my config is removed.
My config_ignore.settings.yml looks like this:
When executing
drush cimmy webforms are removed.The issue started since this specific commit, which was added in #3117135: TypeError: Argument 1 passed to NestedArray::unsetValue() must be of the type array, null given: https://git.drupalcode.org/project/config_ignore/-/commit/1c179cb78ce963...
Comment #5
rajanvalecha12 commentedWhile using 3.x-dev, I found that on config_import, all the ignore config names aren't fetched appropriately. While debugging, I found that this behaviour is because we're looping over config list ($transformation_storage->listAll()) of transformation storage and finding their intersection with ignored_config_etities. However, there might be some configs that're in the destination/sync storage but not in the active storage, due to which we don't fetch the complete list of configs to be ignored.
Here's the patch and it's working for me.
@bircher, I would really appreciate your inputs on this!
Comment #6
rajanvalecha12 commentedComment #7
claudiu.cristeaCould you, please, add a test case to prove this?
Comment #8
jeroentTried the patch locally, but it results in a fatal error:
The listAll method is not possible, since $config_list is an array.
Comment #9
rajanvalecha12 commentedRE: #8, I'm sorry for the mistaken patch. Here's the Updated Patch. Tested manually. I'll add test case later on.
Comment #11
bircherYou have the right idea, but I think it is the wrong approach.
I think the logic needs to be re-ordered.
This means that if there are collections that don't exist in the transformation storage they will be removed by the import/export. We can address collections in a second step easily in #2973431: Ignore configuration storage collections
Comment #12
ayalon commentedWhy can't we use the approach in my patch, that works and supports translations of ignored configurations?
See #3099674: Create 3.x version using the new Drupal 8.8 API
Patch:
https://www.drupal.org/files/issues/2020-02-25/config_ignore-collections...
claudiu.cristea ignored my work and reimplemented the feature himself. But as many here stated, it does not work at all.
My change is small, only a few lines of code at the end of the code to support translations of ignored.
Comment #13
bircherRE #12 I had not reviewed all patches in the previous issue.
I just checked the patch you linked to and the algorithm you used for the transformation looks good (and similar to what I commented in #11.) I don't know why it got lost in comment 34 on that issue.
That said; the patch you linked to also has problems, in particular it uses $this->configFactory, it ignores collections and the top level loop is not efficient. So we can not just go back and use that patch as is. But I would like to encourage you to adapt the current code with the algorithm you devised or the one I alluded to in #11.
Comment #14
kim.pepperTaking a look
Comment #15
kim.pepperI believe this test asserts that ignored config entities are incorrectly deleted.
Comment #17
kim.pepperI tried to wrap my head around the logic in #12 but ran out of time.
Comment #18
claudiu.cristeaCould we provide a test with ConfigWithTranslationTest, which uses Drush to perform the import/export? I really don't trust
ConfigIgnoreBrowserTestBase::doExport(), which seems to ignore the scenario where a config already exists in sync storage but is missed from the active storage. In that case,::doExport()should delete the sync config. But I don't see any line of code where this happens.Comment #19
bircherRE #17: Thanks a lot for taking a look and thanks for the patch.
I think implementing #11 is the most straight forward at this point as the patch linked in #12 has a lot of noise in comparison.
RE: #18: I just checked and yes
\Drupal\Tests\config_ignore\Functional\ConfigIgnoreBrowserTestBase::doExportis very wrong.it should be:
I am pretty sure though that the patch from #15 would still fail and demonstrate the bug here.
Comment #20
kim.pepperLooks like the changes to doExport() do expose some additional test fails.
Comment #22
dpiComment #23
dpitransformStorage)(edit: ignore the first
3117694-active-config.patchfile)Comment #25
dpi\Drupal\Core\Config\ManagedStorage::$manager. Changed test to clone objects without this primed variable before simulating an export.Comment #26
kim.pepperI found unexpected behaviour when manually testing this with the following steps.
Comment #27
kim.pepperMy mistake in #26. That won't match
system.site:nameWhen I fix that. the export/import works perfectly. Thanks @dpi!Comment #28
bircherI am not sure it is correct though.
I understand my previous comments about the algorithm is a bit cryptic. I posted from my phone so I try to explain it again with more detail:
point 1 is addressed very nicely in the last patch.
in the loop we do:
For all ignored config in the destination storage we read it from the destination and set it in the transformation. This is the essence of ignoring config changes. For partially ignored config we merge it smartly, in particular if the transformation storage has it empty we use all of the destination.
Then for all of the ignored config (partially or completely) that exists only in the transformation storage but not in the destination (ie the config in sync but not active when importing or active but not in sync when exporting) we need to decide/configure what to do. (point 6&7 from #11)
Currently in 2.x we do nothing with this, which means that a new webform in the sync directory will be created but then subsequently ignored (assuming you wholesale ignore all webforms) or new blocks will be placed but then they can be changed in prod and subsequently ignored.
But I guess the expectation when exporting is that webforms added in prod are not exported. I can see the case for both so I would make it configurable and leave it to the user. But if everyone here prefers always ignoring I can live with that too.
I just thought it would be clearer to understand what is going on when looking at the code rather than merging the config names from transformation and destination and then deciding what to do depending on if there is data in the storage or not. In particular because if both lists are separate then we know which storage has the data.
We need test for what I described here: #2857247-21: Support for export filtering via Drush We do have this feature now but I still think there is not a great deal of consensus of what should happen and there is no very obvious test that covers all cases next to each other.
Comment #29
larowlanSorry for being a pedant, but an array return is a bit of a code-smell. Are we missing a value-object here?
Comment #30
carolpettirossi commentedJust adding a feedback that #25 works for me.
Comment #31
carolpettirossi commentedMoved to RTBC by mistake. Moving back to Needs work.
But reinforce that it works in my use cases.
Comment #32
acbramley commented+1ing that #25 fixes the issues for us as well.
Re #28 I think this is still quite cryptic (at least for me) and maybe we just need a use-case that is currently not covered by #25, even better if we get a failing test for it.
Comment #33
kim.pepperComment #34
bircherAttached is a patch that implements the algorithm I was talking about and which fixes a bug with config that exists only in certain collections.
It still needs more tests, but maybe we add them when adding different behaviors (like don't ignore the first time it is imported, but always ignore on export etc)
Comment #35
kim.pepperThanks @bircher. I will test this out with one of our sites.
Comment #36
bircherI just did #3186392: Port IgnoreKernelTest from 2.x to 3.x locally and found two more bugs in the patch I wrote. So I will commit that first and then the fixes here.
RE #32 the issue mentioned in the previous paragraph has tests for a few edge cases, and to be honest those kernel tests I added to 2.x is really the only tests I care about.
Comment #37
bircherI also re-tested the patch from #25 just for comparison, if fails locally the same tests my patch does so in that respect the two are fairly equivalent.
Attached is a patch that doesn't fail the tests from 2.x (which are now merged)
Comment #38
bircherinterestingly the test failures are also related to #3117809: TypeError: Argument 1 passed to NestedArray::unsetValue() must be of the type array, null given and so that issue should be resolved with this too.
Comment #42
bircherAdding credits from #3117809: TypeError: Argument 1 passed to NestedArray::unsetValue() must be of the type array, null given and #3203587: TypeError: Argument 1 passed to Drupal\Component\Utility\NestedArray::unsetValue() must be of the type array, bool given
Comment #44
birchera month without complaints, I am committing this now. Thanks everyone for the help!
I will tag a beta release now. Then next up is #3223748: Allow to configure different behaviors. and we make a stable release.
Comment #45
kim.pepperNice work!
Comment #46
acbramley commentedAwesome work, tested the beta and it seems to work nicely!