From 1e6639971f755f1504f6aad43f0f684986dae90b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 Mar 2022 09:44:49 +0100 Subject: [PATCH] StyleSheet: Only set theme on the compiler if it exists The compiler itself can handle invalid themes, but doesn't log the user name which makes it hard to track the cause down. --- library/Icinga/Web/StyleSheet.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index 39611a5a6..7e1993609 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -160,7 +160,16 @@ class StyleSheet } if ($themePath = self::getThemeFile($theme)) { - $this->lessCompiler->setTheme($themePath); + if ($this->app->isCli() || is_file($themePath) && is_readable($themePath)) { + $this->lessCompiler->setTheme($themePath); + } else { + $themePath = null; + Logger::warning(sprintf( + 'Theme "%s" set by user "%s" has not been found.', + $theme, + ($user = Auth::getInstance()->getUser()) !== null ? $user->getUsername() : 'anonymous' + )); + } } if (! $themePath || in_array($theme, self::THEME_WHITELIST, true)) {