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.
This commit is contained in:
Johannes Meyer 2022-03-02 09:44:49 +01:00
parent c5343f5575
commit 1e6639971f

View File

@ -160,7 +160,16 @@ class StyleSheet
}
if ($themePath = self::getThemeFile($theme)) {
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)) {