Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
- Create a new theme by creating a new .info.yml file.
- Enable it.
- You're greeted by a fatal error:
"mytheme.settings config file does not exist."
Cause
theme_get_setting()
expects that each theme has a$theme.settings
default config file.- That does not make sense, because
$theme.settings
contains custom, user-configured settings only. - A theme does not have to provide any custom settings.
Proposed solution
- Remove the bogus requirement.
- While being there, also fix the bogus config schema declaration for theme settings:
- Core declares
theme_settings_default
, but that contains a schema for the optional Shortcut module only. - System module declares
system.theme.global
that contains the actual schema for theme settings, but that is used by System module only. - The individual themes are referencing
theme_settings_default
in their config schema; i.e., their config schema only knows about the aforementioned, bogus Shortcut module declaration.
- Core declares
Comment | File | Size | Author |
---|---|---|---|
#36 | interdiff-25-36.txt | 1.71 KB | effulgentsia |
#36 | theme.settings.36.patch | 12.33 KB | effulgentsia |
#25 | theme.settings.25.patch | 11.85 KB | effulgentsia |
#23 | interdiff.txt | 704 bytes | sun |
#23 | theme.settings.23.patch | 11.85 KB | sun |
Comments
Comment #1
sunComment #2
sundistro.theme-settings.0.patch queued for re-testing.
Comment #3
sundistro.theme-settings.0.patch queued for re-testing.
Comment #4
sundistro.theme-settings.0.patch queued for re-testing.
Comment #5
sunComment #6
sunComment #7
jibranI don't agree with #2 in issue summary but other then that it is simple code moving form one place to other let's see what @alexpott thinks about it?
PS: Is "Sunrise Sanity Cruise" still a thing?
Comment #8
sunI guess this issue is essentially "blocked" on uncertainty/disagreement about the second change described in the issue summary...
To clarify, I'm not 100% sure on that myself — all I'm sure about is that the current config schema definitions do not make sense at all ;-) because:
theme_settings_default
is declared by the core schema (next to othertheme_
config schemata).But that
theme_settings_default
declaration only contains a definition for the optional Shortcut module (in the core schema!)The actual schema for
$theme.settings
config files is defined insystem.theme.global
of System module.The config schema declarations of the actual themes are pointing to
theme_settings_default
instead ofsystem.theme.global
→ the
$theme.settings
configurations are completely lacking a schema right now.Now, this patch fixes the faulty config schema declarations and references.
The only part that I'm not sure about myself is whether the
theme_settings
config schema declaration belongs to core, or whether it belongs to System module...This patch makes core the owner of the
theme_settings
config schema declaration, based on the idea that a theme is an independent extension and not tied to System module in any way. System module just happens to expose a UI to configure theme settings.Does that make sense? :-)
Comment #9
jessebeach CreditAttribution: jessebeach commentedElevated status because it blocks #2232605: Themes cannot be uninstalled.
Comment #10
sunClarified issue summary.
Comment #11
effulgentsia CreditAttribution: effulgentsia commenteddistro.theme-settings.0.patch queued for re-testing.
Comment #13
sunRe-rolled against HEAD.
Comment #15
sun13: drupal8.theme-settings.13.patch queued for re-testing.
Comment #16
jessebeach CreditAttribution: jessebeach commentedI can't find any tests that cover theme settings. Like simply toggle the logo setting. sun, do you know if this exsits offhand? If not, I'll write the coverage.
Otherwise the code looks good and all existing tests pass. As long as the coverage for settings is in place and passes, then let's get this in.
Comment #17
sun#1067408: Themes do not have an installation status introduces some very basic coverage, but technically that's even out of scope for the introduced DUTB test.
We have a web test that verifies different logo paths (focusing on file paths and stuff). But I don't think we have dedicated test coverage for just theme settings.
If we want to introduce test coverage for theme settings here, then (1) it should be a DUTB test (2) it should test nothing else than the expected functionality of
theme_get_setting()
(3) it should ideally not try to assert anything related to a theme's status.That said, as soon as the parent issue lands, the installation status does play a key role with regard to theme settings, because a disabled theme should not have any settings... Without the parent issue, all themes are loaded at all times, so there is no difference between installed/enabled/disabled in HEAD right now.
So the only possible test coverage that I can see with HEAD right now is that
theme_get_settings()
(1) returns System module's defaulttheme.settings.global
configuration if you pass a non-existing theme name, and (2) that it merges the actual theme settings into the global default settings if you pass an existing theme name.I'm suggesting DUTB instead of PHPUnit, because >95% of a PHPUnit test for this would consist of mocking only; barely testing the actual runtime behavior.
Comment #18
sunThat said — strictly speaking, all of that is out of scope.
The only part that would be in scope for this issue would be a test that verifies that a
$theme.settings
file is not actually required.This patch implicitly verifies that by removing various
$theme.settings
files.Explicit test coverage for this would be a very narrow DUTB test — essentially:
The last line blows up without this patch.
Comment #19
sunThe default config for
test_basetheme
is copied/extracted literally from #1067408: Themes do not have an installation statusComment #20
sunOh, hah, obviously, taking it over literally doesn't account for the config schema type change here.
→ Updated config schema type to theme_settings. ;-)
Comment #23
sunUgh.
Restored bartik.settings (required for recent changes to ConfigImportUITest, which I don't want to futz with here).
Comment #24
sunAlright, this patch includes test coverage for the actual bug now (and the new test class can be enhanced later on).
Comment #25
effulgentsia CreditAttribution: effulgentsia commentedReroll.
Comment #27
effulgentsia CreditAttribution: effulgentsia commentedPatch is looking close to ready. My only questions are:
Is this being used by anything?
Looks like we removed this from Stark and Seven, which makes sense as those shouldn't be configurable. But why are we keeping it in Bartik? There doesn't appear to be a UI for configuring it in that theme either.
Comment #28
effulgentsia CreditAttribution: effulgentsia commented25: theme.settings.25.patch queued for re-testing.
Comment #29
xjmComment #30
jessebeach CreditAttribution: jessebeach commentedThe
shortcut_module_link
setting is only set to true in Seven, so we don't need mention of it in Bartik. I've sorted these various settings, see the interdiff.effulgentsia, we should have a way to expose settings defined by a theme's schema. I've added an issue to track that. #2235387: Render schematized theme settings in the theme settings form.
I'm looking into the
override: base
comment.Comment #31
jessebeach CreditAttribution: jessebeach commentedAs far as I can tell
override: base
is not used. It could be removed along with the corresponding scheme declaration. I'll wait for sun to respond, though, because I might not be grepping for the right thing here.Comment #32
jessebeach CreditAttribution: jessebeach commentedAlso, the tests in
ThemeSettingsTest.php
satisfy my concerns from #16. Thanks sun!If #30 comes back green and given a response to the
override: base
comment, I think we're ready to commit this.Comment #34
sunBack to the re-roll in #25.
override: base
:Sorry, my fault, that's copied literally from the parent issue... The additional test coverage over there asserts that theme settings of a base theme can be overridden by a sub-theme. We can remove it here, but we'll add it anyway...?
bartik.settings.yml
+shortcut_module_link
:As mentioned in #23, the new/revised ConfigImportUITest needs that to assert that a theme has been correctly installed and uninstalled when performing a config import. I did not want to change that test, because the visual confirmation of Stark vs. Bartik in the test's verbose browser output helps to manually confirm that the functionality works as expected.
Every configuration file needs a config schema - which is covered by
DefaultConfigTest
. Therefore,bartik.settings.yml
cannot exist and have ashortcut_module_link
key without a corresponding config schema.FWIW, the current theme settings design is seriously flawed in multiple ways:
.info.yml
file.$theme.settings
file, then it has to manually specify the (always identical) config schema for it.$theme.settings
contains an additional configuration option of a module, then the theme's config schema has to manually specify (figure out) the config schema for that option (whereas the originating module does not specify a config schema at all).$theme.settings
overrides the hard-coded default theme settings from.info.yml
.$theme.settings
in the active config storage override the$theme.settings
default config file AND the hard-coded default theme settings from.info.yml
(for keys contained in$theme.settings
).$theme.settings
are not properly maintained and not cleaned up when e.g. the module is uninstalled.$theme.settings
, and in case the base theme config schema changes, there's no controlled way for either of both themes to update$theme.settings
.In essence, this patch here only duct-tapes the situation for now. This entire design needs complete rethinking.
Comment #35
sunCreated #2235901: Remove custom theme settings from *.info.yml for #34.2, since that is not to be addressed here.
Comment #36
effulgentsia CreditAttribution: effulgentsia commentedThanks for opening that issue. How about this then? Interdiff relative to #25 attached. I'm happy with this, so if you approve the interdiff, this can be RTBC.
Comment #37
sunSure :)
Comment #38
jessebeach CreditAttribution: jessebeach commentedNeat. Progress obtains.
Comment #39
effulgentsia CreditAttribution: effulgentsia commentedIn case the core committer reviewing this wonders why those labels make no sense, it's because this is a pre-existing bug in HEAD, and this patch just moves it from one file to another. After this is committed, we can fix the labels in #2236089: theme_settings schema duplicates the label "Shortcut icon settings" where it doesn't make sense.
Comment #40
xjmLet's have @alexpott take a look at this one.
Comment #41
alexpottThanks for opening the two followups. When we converted theme settings to config I remember thinking the current architecture is a bit of a mess.
Committed 7f00c59 and pushed to 8.x. Thanks!
Comment #43
sunThanks!