Problem/Motivation
#2352949: Deprecate using Classy as the default theme for the 'testing' profile introduced the $defaultTheme property on functional tests and the behavior associated with that. It's proven to work well.
Except in one case: when the theme provides required configuration that depends on a module already being installed. Yes, #474684: Allow themes to declare dependencies on modules hasn't landed yet, but the Seven theme has been doing this for ages, as does https://www.drupal.org/project/claro, which is being added in #3079738: Add Claro administration theme to core.
This causes failures like:
1) Drupal\Tests\claro\Functional\ClaroTest::testRegressionMissingElementsCss
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for claro.settings with the following errors: claro.settings:third_party_settings.shortcut missing schema
/Users/wim.leers/Work/d8/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php:95
/Users/wim.leers/Work/d8/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111
/Users/wim.leers/Work/d8/core/lib/Drupal/Core/Config/Config.php:231
/Users/wim.leers/Work/d8/core/lib/Drupal/Core/Config/ConfigInstaller.php:378
/Users/wim.leers/Work/d8/core/lib/Drupal/Core/Config/ConfigInstaller.php:137
/Users/wim.leers/Work/d8/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php:75
/Users/wim.leers/Work/d8/core/lib/Drupal/Core/Extension/ThemeInstaller.php:188
/Users/wim.leers/Work/d8/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:435
/Users/wim.leers/Work/d8/core/tests/Drupal/Tests/BrowserTestBase.php:570
/Users/wim.leers/Work/d8/core/tests/Drupal/Tests/BrowserTestBase.php:398
Discovered this in #3086435: Add automated test coverage for Claro.
Proposed resolution
Install after modules and use the correct container.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | 3087036-26.patch | 1.63 KB | _utsavsharma |
| #26 | interdiff_d10.txt | 1.63 KB | _utsavsharma |
| #5 | 3087036-5.patch | 2.81 KB | alexpott |
| #5 | 2-5-interdiff.txt | 2.42 KB | alexpott |
| #2 | 3087036-2.patch | 2.88 KB | alexpott |
Issue fork drupal-3087036
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
alexpottThis allows us to add test coverage and we could have done it this way to start - so I'm not sure we need to add a test here.
Comment #3
wim leersHah … I told you I was gonna file this issue for you, but I guess you didn't see that 😭
Merging issue metadata from #3087043: Follow-up for #2352949: themes that include required configuration that depends on modules not handled correctly and closed it.
Comment #4
wim leersManually tested with #3086435-13: Add automated test coverage for Claro. This core patch makes that patch pass tests. 🥳
If we commit this, then #3086435-13: Add automated test coverage for Claro can become part of Claro, and then once Claro lands in core via #3079738: Add Claro administration theme to core, we'll have test coverage for this.
The only alternative way to add test coverage for this is to add a new test-only theme with required configuration that depends on a module. That seems excessive?
Tempted to RTBC. Thoughts?
Comment #5
alexpottI can write a better comment.
Comment #8
alexpottYay chickens and eggs...
If we install the theme after modules then test modules which have been able to assume the presence of a theme break.
And if we install the theme before modules... we can’t turn off config schema checking just for whilst installing the default them and we can’t set static::$configSchemaCheckerExclusions[] because that only works when strict config schema is disabled.
Fun.
Comment #9
wim leersComment #10
alexpottGonna move this to the theme system because the problem is really being caused by theme settings.
Theme's need to ship with config files that define their defaults for theme settings that don't exist yet. Seven (and Claro) are doing this. So seven.settings.yml looks like:
but it doesn't depend on Shortcut and there's no requirement that shortcut is around when seven is installed.
Also this "third_party_settings" isn't the same as a config entities third party settings - it's doesn't get cleaned up - because seven.settings (and any theme settings config) is not a config entity.
Comment #11
alexpottHere are some options:
Not sure which way to go.
Comment #12
effulgentsia commentedI grepped core for
theme_get_setting('third_party_settingsand Shortcut is the only example using this pattern.My initial reaction to reading #10 and #11 is that we should do #11.4, except maybe flip the name order to
THEME.MODULE.settings.yml, and then maybe introduce either a new function (e.g.,theme_get_module_specific_setting()) to read from it, or add an optional $module parameter to the existingtheme_get_setting()function.However, I don't think we can break BC of the existing
third_party_settings.shortcut.module_linktheme setting. To continue to handle that specific case, I wonder if we should fixshortcut_themes_installed()andshortcut_install()to instead of hard-coding'seven', to invoke an alter hook for determining which themes to apply that logic to. I'm suggesting an alter instead of some other hook, because we already haveThemeManager::alter().Comment #13
effulgentsia commented#10 changed the component of this issue, so is the title of this issue still what we want? Or is the issue something more like "third_party_settings in THEME.settings.yml cannot be dependency managed"?
Comment #14
effulgentsia commentedActually, just changing the title. Feel free to change it back if we want to rescope the issue to just testing setup fixes.
Comment #15
wim leersLet's take a step back.
shortcut-integration-supported: truekey-value pair in their*.info.ymlfileshortcut.settings.ymlthat allows this to be enabled per themeLong story short: let's not spend a lot of time on building somethign complex if it will only ever be used by a single module that is infamous for its weird architecture.
Comment #18
heddnJust tripped on this with the gin admin theme. Its causing config schema errors now on gin admin theme.
Comment #19
berdir#15 3.2 sounds like the easiest fix to me for storing such information. I don't think we should hardcode it on admin themes, that's not what this is about. there could be sites where having this in the frontend theme could be useful and it's also not something that the theme can/needs to decide on.
THEME.settings.yml is simple config, and other modules shouldn't mess with simple config of other modules or themes.
Comment #26
_utsavsharma commentedPatch for 10.1.x.
Comment #28
hudriI think I've got a related problem: My module has theme-specific settings. Previously I just stored my modules config settings in the root of theme.settings.yml. Inspired by the shortcut module, I now wanted to clean this up and move it into third party settings. Basically I wanted to update my config from
to a proper schema
and proper third party settings
The form hook is something like
This does not work correctly, there are two problems:
1) The schema is not used/validated, the boolean value is still stored as (int) 0 / 1 and not as (bool) true / false
2) When submitting the form, it saves all my values, but wipes the existing config from shortcut module.
Reading @berdir's comment, is shortcut a bad example? Should I avoid third party settings for themes at all?
Update:
Tested the new
#config_targetinstead of#treeand#default_value, but also does not work. It reads the existing values, but on save the schema validation seems to fail ('tailwind_jit' is not a supported key, but do I do have a schema file)Comment #29
bbrala