Problem/Motivation
Sibling issue for config entities: #2869792: [meta] Add constraints to all config entity types.
Similar as we want to expose UPDATE functionality for config entities, (see #2869792: [meta] Add constraints to all config entity types / #2300677: JSON:API POST/PATCH support for fully validatable config entities) we want to also add support for simple configuration, see #2911319: Provide a single command to install & run Drupal / #2949888: Enhance config schema for richer default experiences).
In order to safely expose configuration entities we need to add constrains to simple configurations, like the system.site
configuration.
Proposed resolution
Add validation to all simple config in core.
- Find all non-test
type: config_object
occurrences in Drupal core:grep -r --include=\*.schema.yml --exclude=*/tests/* 'type: config_object' ./core
- There's 50 in
11.x
on Apr 29, 2024 👆:$ grep -r --include=\*.schema.yml --exclude=*/tests/* 'type: config_object' ./core | wc -l 50
- In the Standard install profile, there's 38:
$ ./vendor/bin/drush ev "print count(array_filter(\Drupal::service('config.typed')->getDefinitions(), fn (array \$def) => (\$def['type'] ?? '') === 'config_object'))" 38
- of which (currently) 22 are fully validatable:
$ ./vendor/bin/drush ev "print count(array_filter(\Drupal::service('config.typed')->getDefinitions(), fn (array \$def) => (\$def['type'] ?? '') === 'config_object'&& array_key_exists('FullyValidatable', \$def['constraints'] ?? [])))" 22
Remaining tasks
So let's generate a TODO list for us:./vendor/bin/drush ev "\$simple = array_filter(\Drupal::service('config.typed')->getDefinitions(), fn (array \$def) => (\$def['type'] ?? '') === 'config_object'); print implode(\"\n\", array_map(fn (\$name, \$def) => '<li>' . ((array_key_exists('FullyValidatable', \$def['constraints'] ?? [])) ? '✅' : '') . '<code>' . \$name .'
', array_keys(\$simple), array_values(\$simple)))"
The output of 👆 copy/pasted into this issue summary:
theme_settings
core.extension
core.menu.static_menu_link_overrides
- ✅
announcements_feed.settings
- ✅
automated_cron.settings
- ✅
comment.settings
- ✅
contact.settings
- ✅
dblog.settings
- ✅
field.settings
- ✅
field_ui.settings
file.settings
- ✅
filter.settings
- ✅
image.settings
- ✅
menu_ui.settings
- ✅
node.settings
- ✅
search.settings
system.site
- ✅
system.maintenance
- ✅
system.cron
- ✅
system.date
- ✅
system.diff
- ✅
system.logging
system.performance
system.rss
system.theme
system.file
- ✅
system.image
- ✅
system.image.gd
system.mail
- ✅
system.advisories
- ✅
system.feature_flags
- ✅
taxonomy.settings
- ✅
text.settings
user.settings
user.mail
user.flood
views.settings
(See the Child issues
in the sidebar to find the issues for the not-yet-validatable ones.)
Total: 22/50 = 44%
Standard: 22/38 = 58%
Last updated: April 29, 2024.
User interface changes
None.
API changes
None.
Data model changes
None.