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