Skip to content

DEV: Fix theme site setting flakiness part 2 #33813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

martin-brennan
Copy link
Contributor

In certain scenarios in the specs, we are ending up in
a situation where the default theme has been changed,
but Theme.user_theme_ids does not contain that theme's
ID, even though it should have the default theme ID. This
means that the default theme isn't selected as the
application_controller @theme_id, which is usually used
to get the correct theme site setting values from the cache.

This is happening because we need to clear the Theme cache
every time this changes. Usually this would happen via
theme.set_default!, but this isn't consistently used,
and we don't want to end up in a bad state when people use
SiteSetting.default_theme_id= directly.

This commit fixes the flakiness by moving Theme.expire_site_cache!
to the main site setting change tracker, this way it's always called
whenever the setting changes.

In certain scenarios in the specs, we are ending up in
a situation where the default theme has been changed,
but `Theme.user_theme_ids` does not contain that theme's
ID, even though it should have the default theme ID. This
means that the default theme isn't selected as the
application_controller `@theme_id`, which is usually used
to get the correct theme site setting values from the cache.

This is happening because we need to clear the Theme cache
every time this changes. Usually this would happen via
`theme.set_default!`, but this isn't consistently used,
and we don't want to end up in a bad state when people use
`SiteSetting.default_theme_id=` directly.

This commit fixes the flakiness by moving `Theme.expire_site_cache!`
to the main site setting change tracker, this way it's always called
whenever the setting changes.
@martin-brennan martin-brennan merged commit 627b609 into main Jul 24, 2025
17 checks passed
@martin-brennan martin-brennan deleted the dev/fix-flakys-tss-again branch July 24, 2025 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants