From 7b6912ba9860449f948d142a0c43a9f0540d93d9 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Wed, 14 Aug 2019 17:22:53 +0800 Subject: [PATCH] Use default theme if loaded one is not found When loading a user's theme, make sure it's installed. Also, when determining the default theme, account for the situation in which zero themes are installed (and use 'default' then). Refs #1061 --- include/functions_user.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 593d17aef..df33f29ce 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -299,9 +299,10 @@ function build_user($user_id, $use_cache=true) } // Check user theme - if (!isset($user['theme_name'])) + if (!isset($user['theme_name']) || !check_theme_installed($user['theme_name'])) { $user['theme'] = get_default_theme(); + $user['theme_name'] = $user['theme']; } return $user; @@ -777,7 +778,7 @@ function get_default_theme() // let's find the first available theme $active_themes = array_keys(get_pwg_themes()); - return $active_themes[0]; + return isset($active_themes[0]) ? $active_themes[0] : 'default'; } /**