From fc2c20850d3f8ec326a6a453075e705997d3f9c6 Mon Sep 17 00:00:00 2001 From: albertlast Date: Wed, 9 Sep 2026 05:50:16 +0200 Subject: [PATCH] Offers the default variant wherever the variant list is built Theme::loadVariant() prepends a variant named 'default' to whatever a theme declares in theme_variants, so that is the list a member is actually served from. Two other places build their own list by reading theme_variants out of a theme's index.template.php and never add it: the variant settings on the admin theme page, and the variant picker a member chooses a theme with. The picker is where it shows. A member whose stored variant is 'default' finds it missing from the list it checks against, so the selection falls back to the first variant the theme declares and the picker offers no way back to the one they had. Co-Authored-By: Claude Opus 5 Signed-off-by: albertlast --- Sources/Actions/Admin/Themes.php | 4 ++++ Sources/Actions/ThemeChooser.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Sources/Actions/Admin/Themes.php b/Sources/Actions/Admin/Themes.php index bca5bd7677..ba5ed00bcc 100644 --- a/Sources/Actions/Admin/Themes.php +++ b/Sources/Actions/Admin/Themes.php @@ -884,6 +884,10 @@ public function setSettings(): void if (!empty(Theme::$current->settings['theme_variants'])) { Utils::$context['theme_variants'] = []; + // Theme::loadVariant() offers a variant named 'default' alongside + // whatever the theme declares, so it belongs in this list too. + Theme::$current->settings['theme_variants'] = array_unique(array_merge(['default'], Theme::$current->settings['theme_variants'])); + foreach (Theme::$current->settings['theme_variants'] as $variant) { // Have any text, old chap? Utils::$context['theme_variants'][$variant] = [ diff --git a/Sources/Actions/ThemeChooser.php b/Sources/Actions/ThemeChooser.php index 4ebaa6e05e..3005630bcf 100644 --- a/Sources/Actions/ThemeChooser.php +++ b/Sources/Actions/ThemeChooser.php @@ -294,6 +294,10 @@ public function execute(): void eval(($matches[1] === '$' ? 'global $settings; ' : 'use SMF\\Theme; ') . $matches[0]); if (!empty(Theme::$current->settings['theme_variants'])) { + // Theme::loadVariant() offers a variant named 'default' alongside + // whatever the theme declares, so it belongs in this list too. + Theme::$current->settings['theme_variants'] = array_unique(array_merge(['default'], Theme::$current->settings['theme_variants'])); + foreach (Theme::$current->settings['theme_variants'] as $variant) { Utils::$context['available_themes'][$id_theme]['variants'][$variant] = [ 'label' => Lang::txtExists('variant_' . $variant) ? Lang::getTxt('variant_' . $variant) : $variant,