Allow configs to be enforced by default

Created on 11 April 2025, about 1 month ago

Problem/Motivation

I often forget to enforce relevant configs, since you explicitly have to flag them for enforcement. For example, when I add a new field, I might remember to enforce the field storage and instance settings, but to enforce form and view display settings.

It'd be nice to be able to automatically enforce all configs from any config forms that I've saved.

Proposed resolution

We could add a global setting to enforce configs by default. That way, when we interact with any new config form, the "enforce config" checkbox will be checked, and we won't have to remember to do so. Once we've worked out the kinks, I'd even suggest making that the default behaviour (maybe in v2).

One challenge here is that we assume that any config that is not stored in a target module registry is not enforced. When we load the config enforce form, how would we be able to differentiate between (a) not having yet interacted with this config, versus (b) having disabled enforcement for it? It doesn't even make sense to store such data in a target module registry (ie. which registry should be responsible for not enforcing the foo.bar config?)

I think the solution lies in leveraging our "unenforced configs" setting. When handling the submission of a config enforce form, if (and only if) we're enforcing by default, we can add the related config to config_enforce_devel.settings.ignored_configs. This setting currently has no effect on the CED form itself. However, when building the form (and we're enforcing by default), we could disable the "enforce" checkbox, if the related config is in ignored_configs.

Remaining tasks

TBD

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada ergonlogic Montréal, Québec 🇨🇦

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ergonlogic
  • First commit to issue fork.
  • 🇨🇦Canada star-szr

    While working on tests, spotted this:

    Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for config_enforce_devel.settings with the following errors: config_enforce_devel.settings:defaults.config_directory missing schema, config_enforce_devel.settings:defaults.enforcement_level missing schema, config_enforce_devel.settings:defaults.enforce_dependencies missing schema, config_enforce_devel.settings:ignored_configs missing schema in Drupal\Core\Config\Development\ConfigSchemaChecker->onConfigSave() (line 94 of core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php).

  • Merge request !33Resolve #3518869 "Enforce by default" → (Open) created by Unnamed author
  • Pipeline finished with Failed
    25 days ago
    Total: 192s
    #481511
  • Pipeline finished with Failed
    25 days ago
    Total: 288s
    #481535
  • Pipeline finished with Failed
    20 days ago
    #485871
  • 🇨🇦Canada star-szr

    The tests are running successfully in GitLab CI now with the work from 📌 Fix PHP deprecations Active merged.

    My next steps are:

    • Expand the test coverage to include the "ignore" part of the functionality and anything else that may be missing
    • Enhance the UI/better incorporate the checkbox
  • 🇨🇦Canada star-szr

    This is ready for review/testing and I've updated the issue summary.

Production build 0.71.5 2024