Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292677

Add validation constraints to `type: theme_settings`

$
0
0

Problem/Motivation

Per #3395555-22: Add validation constraints to olivero.settings, type: theme_settings not being fully validatable means not a single theme's settings can be fully validatable!

Steps to reproduce

N/A

Proposed resolution

Determine appropriate validation (and config schema tweaks) for:

  1. theme_settings:favicon.*mimetype, path, url only make sense if use_default is set to FALSE. The more elegant solution would be to only allow any key besides use_default if use_default is set to FALSE. But that'd require virtually every theme in existence to modify their default settings. So instead, add validation logic that requires each of these to be NULL if use_default === TRUE, and requires a valid value otherwise.
  2. theme_settings:logo.*→ same as for *:favicon.*
  3. theme_settings:features.*→ this one is very tricky. The last significant work in this area was in 2018, in #2954884: Cannot save theme settings form for themes without logo or favicon features. core/modules/system/tests/themes/test_theme_settings_features/test_theme_settings_features.info.yml correctly defines a features key in the theme's *.info.yml file. But not a single core theme does this! 😱 Which means that
    function _system_default_theme_features() {
      return [
        'favicon',
        'logo',
        'node_user_picture',
        'comment_user_picture',
        'comment_user_verification',
      ];
    }
    

    applies to all core themes (or any other theme that doesn't specify features in its *.info.yml).

    AFAICT this means that in principle every theme that specifies features in its *.info.yml with only a subset of _system_default_theme_features() MUST specify a corresponding tweak to type: theme_settings, for example the test_theme_settings_features theme's

    features:
      - node_user_picture
      - comment_user_picture
      - comment_user_verification
    

    SHOULD REQUIRE a corresponding:

    test_theme_settings_features.settings:
      type: theme_settings
      label: 'Test theme settings'
        features:
          type: mapping
          label: 'Optional features'
          mapping:
            comment_user_picture:
              type: boolean
              label: 'User pictures in comments'
            comment_user_verification:
              type: boolean
              label: 'User verification status in comments'
            node_user_picture:
              type: boolean
              label: 'User pictures in posts'

    … and the absence of this config schema tweak should result in a deprecation error.

    Similarly, the absence of default configuration for each of these should also result in a deprecation error.

    This part definitely requires theme subsystem maintainer review.

FYI, previous work on this area:

Remaining tasks

Get theme subsystem maintainer approval for the proposed resolution.

User interface changes

None.

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD


Viewing all articles
Browse latest Browse all 292677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>