Problem/Motivation
While working on a site involving the contrib Workflow module, we noticed that workflow States were not being picked noticed as "enforceable" config forms. This appears to be due to the way the /admin/config/workflow/workflow/my_workflow/states form is built using a ConfigEntityListBuilder form builder class, which Config Enforce doesn't recognize as a config-related form.
Steps to reproduce
- Install a site with Config Enforce, Config Enforce Devel, and Workflow (contrib) modules
- Create a workflow entity (eg.
my_workflow). Notice that Config Enforce will pick up the base entity - Create some workflow States
- Notice that the Config Enforce UI is missing from the
/admin/config/workflow/workflow/my_workflow/statespage.
Workaround: We found that the State configs could still be enforced properly using Config Enforce Devel's "Generate from Active Storage" feature, under the Enforced Configs /admin/config/development/config_enforce/enforced_configs page. The issue is purely with the ConfigResolver class recognizing these State config entities on their config form page.
Proposed resolution
By extending ConfigResolver to be aware of ConfigEntityListBuilder-based config forms, we should be able to support recognizing any config entities on such a form by loading the list of entities from the FormBuilder, iterating over the config entities, and returning the list of their names.
Remaining tasks
- 🗸 Roll a patch to recognize ConfigEntityListBuilder forms in ConfigResolver
- Write a test case to validate the functionality
User interface changes
The Config Enforce Devel form will show up correctly on config forms based on ConfigEntityListBuilder.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | config_enforce-support_config_entity_list-3352380-1.patch | 1.75 KB | spiderman |
Issue fork config_enforce-3352380
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:
Comments
Comment #3
spidermanI've uploaded a static patch file based on the current state of the MR, for inclusion in composer.json as needed.
Comment #4
ambient.impactComment #5
ambient.impactAfter poking around in the code (both ours and core), I've come up with the following possibilities:
ConfigEntityListBuilder, it looks like this is used for a whole bunch of things in core, so one way we can test this is to install a few of the core modules that extend the class, and then navigate to each route that makes use of that; for example, the block module uses this for the block list admin page (admin/structure/block).ConfigEntityListBuilderin a test module and use those for our tests.I propose we go with the first option initially, and open a follow up issue to implement the second method down the road.
Comment #6
ambient.impactHmm, upon investigation, it seems a lot of the instances in core aren't actually forms but output as tables or similar structures, which means that we don't even end up with
ConfigResolverbeing created on a lot of them and the few that it does end up getting created for don't actually get far enough to be identified as having a config entity list. The one that does seem to work is the block list. Will investigate further.Comment #7
ambient.impactComment #8
ambient.impactMarking as ready so that tests can run.
Comment #9
ambient.impactComment #10
spidermanThis looks great to me! I think relying on a core module's (esp the venerable
block.module) implementation here is reasonable, since any changes there should likely result in some kind of change in our module as well. We'd either want to support the new implementation and/or adapt the current one. This also saves us some boilerplate in the test code, which is a nice upside :)I'd love to see a follow-on ticket to add tests for the other types of config
ConfigResolversupports, namely "simple" config, basic Config Entities, and Plugin-based Config Entities. With the new Trait introduced in #3353064: Create a test trait to abstract repetitive UI checks/asserts, along with the example set here, these should be trivial to implement, but increase the value of our test suite quite a bit.Thanks @Ambient.Impact!
Comment #12
ambient.impactHas been merged!