[meta] Add constraints to all simple configuration

Created on 11 March 2018, almost 7 years ago
Updated 4 August 2024, 5 months ago

Problem/Motivation

Sibling issue for config entities: 🌱 [meta] Add constraints to all config entity types Active .

Similar as we want to expose UPDATE functionality for config entities, (see 🌱 [meta] Add constraints to all config entity types Active / [PP-2] POST/PATCH config entities via REST for config entity types that support validation Needs work ) we want to also add support for simple configuration, see #2911319: Provide a single command to install & run Drupal / 🌱 Enhance config schema for richer default experiences Active ).

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 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.

🌱 Plan
Status

Active

Version

11.0 🔥

Component
Configuration 

Last updated 3 days ago

Created by

🇩🇪Germany dawehner

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024