Problem/Motivation
While working on test coverage for configuration schema improvements, I stumbled upon olivero.settings behaving weirdly.
turns out it's because its config schema is wrong, it does:
olivero.settings:
type: theme_settings
label: 'olivero settings'
mapping:
third_party_settings:
type: mapping
label: 'Third party settings'
mapping:
shortcut:
type: mapping
label: 'Shortcut'
mapping:
module_link:
type: boolean
label: 'Module Link'
mobile_menu_all_widths:
…
site_branding_bg_color:
…
base_primary_color:
…
but
theme_settings already has
theme_settings:
…
third_party_settings:
# Third party settings are always optional: they're an optional extension
# point.
requiredKey: false
type: sequence
label: 'Third party settings'
sequence:
type: theme_settings.third_party.[%key]
which combined with shortcut.schema.yml's
# Schema for theme settings.
theme_settings.third_party.shortcut:
type: mapping
label: 'Shortcut settings'
mapping:
module_link:
type: boolean
label: 'Add shortcut link'
Means that the entirety of that override should be removed.
Raised in #3111409-123: Add new Olivero frontend theme to Drupal 9.1 core as beta by @catch but it was never answered.
Steps to reproduce
Proposed resolution
Remove the pointless overrides.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comments
Comment #2
wim leersComment #4
smustgrave commentedSurprised that removing that cause all those failures. Is it a dependency thing where those other schemas aren't getting loaded?
Comment #5
wim leersQuite possibly the Shortcut module must be installed in all those failing tests.
I see lots of migration test failures. 90% likely that the migration is wrong (i.e. assumes the Shortcut module is installed, which is not guaranteed).
Comment #6
wim leersComment #7
smustgrave commentedAh good find!
Comment #8
longwaveWhat about existing sites? Do we need to clean up if Olivero is installed but Shortcut is not?
Comment #9
smustgrave commentedYou are correct. Did a standard install, uninstalled shortcut, config export and still see that third_party_setting in the yml file.
Comment #10
wim leersMost sites don't need an update path, for two reasons:
type: theme_settings.third_party.shortcut, and hence their config is validThat means we need to write an update path for the remaining 1% of sites that use Olivero but have the Shortcut module uninstalled, because in those cases, the third party settings in
olivero.settingsare meaningless noise.(Sorry for maybe stating the obvious, but I was thinking it through so might as well write it up.)
olivero_post_update_add_olivero_primary_color()andOliveroPostUpdateTestalready exist and provide a decent example :) At the start of the post-update function, we'd need something like:(example of that:
help_post_update_help_topics_search())Comment #11
borisson_Postponing this on #3395555: Add validation constraints to olivero.settings, which adds more validation.
Comment #12
wim leersComment #13
hudriThis bug is a bit annoying.
Contrib (e.g. Gin) is now copying this bug into their own codebase, just to make Config inspector shut up. And this again breaks theme 3rd party settings for everybody else :(
Comment #14
bbralaIssue itr was postponed on was fixed, this can actually be worked on.
Comment #15
bbralaAdded an update hook and test, also tested it locally on a clean install.
Comment #16
smustgrave commentedSo tested this one with 2 separate sites, 1 I had shortcuts installed the other I did not
First site
> Shortcut remained
Second site
> Shortcut was removed
Problem though, on the site that remained the validation went down because the third_party_settings schema is gone.
Comment #17
bbralaWhat was the message there?
The validation should still be OK, since:
Which means core.data_types.schema.yml
Which then should resolve into:
shortcut.schema.yml
I also tried to proove the issue in the test, but seems fine. I'm confused.
Comment #18
smustgrave commentedDon't have that branch up right now but validation had gone down for me because third_party_settings was no longer validated
Comment #19
bbralaCan you help me reproduce locally?
Comment #20
smustgrave commentedSo I apply the MR and run the update when I go to olivero.settings
I see that the percentage went down to 94% and
Comment #21
bbralaAhh, there.
Hmm, ok, seems weird but can look into that. I'd assume that is validated since it is not overwritten for the theme_settings type.
Thanks, I cab work with this.
Comment #22
bbralaI should confess i first read your message as the validation crashed, but you mean it is not 100% :)
This goed a little deeper. I dont see any third_party_settings validated in other config, only the actualyl settings when set, so this seems expected. There is also;
#3087036: third_party_settings in THEME.settings.yml cannot be dependency managed
#3016895: 3rd party should be allowed to add config dependencies
Which expose some issues around third part settings. So i don't think we should block on the fact the parent key is not validated.
Comment #23
bbralaComment #24
smustgrave commentedAlright that was the only issue I found
Comment #25
alexpottThis is going to change what is set up when you install olivero with shortcuts already enabled. This must change what happens when you install standard.
I think we need to go a little further and introduce a little bit of cleverness into the theme installer. Something along the lines of:
Comment #26
alexpottPerhaps more elegant:
Comment #27
bbralaSeems like a good suggestion to add that.
Added the extra removal, and rebased while i was at is.
Comment #28
dcam commentedThat isn't a random test failure. I verified the failure multiple times on my local environment. I didn't look into it, but it appears to have something to do with Olivero's third party settings. So it seems likely that it has something to do with the most recent changes. Because of that I didn't review those changes.
Comment #29
bbralaFixed missing annotation.
Comment #30
dcam commentedModifying a theme's configuration when it's installed seems like something we should have tests for. Otherwise I think the changes that resulted from the increase in scope from #25 look OK to me, with one minor bit of feedback.
Comment #31
bbralaWe have
OliveroPostUpdateTestwhich at least checks if removal is done properly.What would you like to see tested? If other settings are kept? Not sure what you are asking more coverage for.
Comment #32
dcam commentedSorry, I was talking specifically about the change to
ThemeInstaller. The update test looks good. But #25 caused the addition of new functionality. I think that a Kernel test that verifies third-party settings are removed/retained from a theme's settings when it's installed is necessary. I looked for an existing test for that, but didn't find one. I might have looked in the wrong places.Comment #33
oily commentedRemove 'Needs tests' tag. Coverage is in place.
Comment #34
oily commentedTest-only output:
Comment #35
oily commentedIt seems like #32 has been addressed now? Setting to Needs review.
Comment #36
oily commentedComment #37
dcam commentedThat was an update test. But there was functionality added to the ThemeInstaller that also needs to be tested.