From c0f5906dcec0fc02a80047a216fd8a7dc5a37095 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Mon, 12 Apr 2021 12:05:50 +0200 Subject: [PATCH] Fix crash when accessing a backoffice page in maintenance mode (regression from e2f30182) --- application/themehandler.class.inc.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/application/themehandler.class.inc.php b/application/themehandler.class.inc.php index 50e96ca4a..110b68345 100644 --- a/application/themehandler.class.inc.php +++ b/application/themehandler.class.inc.php @@ -73,10 +73,7 @@ class ThemeHandler public static function GetApplicationThemeId(): string { try { - if (is_null(MetaModel::GetConfig())) { - throw new CoreException('no config'); - } - $sThemeId = MetaModel::GetConfig()->Get('backoffice_default_theme'); + $sThemeId = utils::GetConfig()->Get('backoffice_default_theme'); } catch (CoreException $oCompileException) { // Fallback on our default theme in case the config. is not available yet @@ -96,8 +93,7 @@ class ThemeHandler $sThemeId = null; try { - $oConf = MetaModel::GetConfig(); - if ((!is_null($oConf)) && (true === $oConf->Get('user_preferences.allow_backoffice_theme_override'))) { + if (true === utils::GetConfig()->Get('user_preferences.allow_backoffice_theme_override')) { $sThemeId = appUserPreferences::GetPref('backoffice_theme', null); } } @@ -188,7 +184,8 @@ class ThemeHandler { try { // Try to compile theme defined in the configuration - $sThemeId = static::GetCurrentUserThemeId(); + // Note: In maintenance mode we should stick to the app theme (also we don't have access to many PHP classes, including the user preferences) + $sThemeId = SetupUtils::IsInMaintenanceMode() ? static::GetApplicationThemeId() : static::GetCurrentUserThemeId(); static::CompileTheme($sThemeId); } catch (CoreException $oCompileException) {