Theme specific configurations always override the global configuration

Created on 2 April 2017, about 7 years ago
Updated 30 January 2023, over 1 year ago

Problem/Motivation

Once a theme's configuration has been saved, it is impossible to revert the theme back to use the global configuration.

Steps to Reproduce

- Install a clean Drupal 8.3.x site
- Go to the global theme configuration page /admin/appearance/settings define some settings and save the form.
- Go to a theme (Bartik) specific configuration page /admin/appearance/settings/bartik see the same settings as defined above.
- Change some settings in Bartik's configuration and save the form.
- Make some more changes to the global theme config and notice they are not visible in the website, nor in the theme specific config.

Discoveries so far

theme_get_setting() will always use the theme specific configuration (if defined) to override the global configuration:

    $cache[$theme]->setData(\Drupal::config('system.theme.global')->get());

    // Get the values for the theme-specific settings from the .info.yml files
    // of the theme and all its base themes.
    $themes = \Drupal::service('theme_handler')->listInfo();
    if (isset($themes[$theme])) {
      $theme_object = $themes[$theme];

      // Retrieve configured theme-specific settings, if any.
      try {
        if ($theme_settings = \Drupal::config($theme . '.settings')->get()) {
          $cache[$theme]->merge($theme_settings);
        }
      }
      catch (StorageException $e) {
      }

The only way to get it back to default is to remove the bartik.settings configuration (or one single key from it). I think there should be a way to 'reset' a theme setting and to fall back to the globally defined setting.

Proposed resolution

1. Apart from TRUE/FALSE on the theme specific configuration form, allow a third value to indicate the value should follow the global configuration.

2. Reverse the theme_get_setting() logic and make sure that a global configuration always overrides a theme specific implementation. But also here a 3rd value is required: Force enabled, force disabled, not enforcing.

Remaining tasks

- Decide on the resolution.
- Rework the theme_get_setting() logic accordingly.

User interface changes

Before:

After:

- 'Inherit Global' is referring to the global settings
- Styling of radio's is achieved after committing #2236789: Styling of inline radios broken: inappropriate trailing colons (breaks EditorImageDialog) .

API changes

TBD

Data model changes

The theme settings are still boolean values, however tests had to be adjusted to use integer values during submission (boolean values are not in the options allowed list and were ignored).

🐛 Bug report
Status

Needs work

Version

10.1

Component
Theme 

Last updated about 2 hours ago

Created by

🇳🇱Netherlands Neograph734 Netherlands

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

  • Needs product manager review

    It is used to alert the product manager core committer(s) that an issue represents a significant new feature, UI change, or change to the "user experience" of Drupal, and their signoff is needed. If an issue significantly affects the usability of Drupal, use Needs usability review instead (see the governance policy draft for more information).

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.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Production build 0.69.0 2024