[meta] Add constraints to all simple configuration

Created on 11 March 2018, about 6 years ago
Updated 3 April 2024, 10 days 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 52 in 11.x on Mar 13, 2024 πŸ‘†:
    $ grep -r --include=\*.schema.yml --exclude=*/tests/* 'type: config_object' ./core | wc -l
          52
    
  • In the Standard install profile, there's 37:
    $ ./vendor/bin/drush ev "print count(array_filter(\Drupal::service('config.typed')->getDefinitions(), fn (array \$def) => (\$def['type'] ?? '') === 'config_object'))"
    37
    
  • of which (currently) 15 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'] ?? [])))"
    15
    

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: 15/52 = 29%
Standard: 15/37 = 41%

Last updated: April 3, 2024.

User interface changes

None.

API changes

None.

Data model changes

None.

🌱 Plan
Status

Active

Version

11.0 πŸ”₯

Component
ConfigurationΒ  β†’

Last updated about 13 hours 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 : some issue and comment data are missing.

Production build https://api.contrib.social 0.62.1