From aa101e18c84f4afc50c6aecc42d31e60f0cbe7b5 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 2 Nov 2021 15:09:26 +0100 Subject: [PATCH 1/2] PreferenceForm: Don't try to load missing themes --- application/forms/PreferenceForm.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/forms/PreferenceForm.php b/application/forms/PreferenceForm.php index 7fd9b02d0..b60de4dc8 100644 --- a/application/forms/PreferenceForm.php +++ b/application/forms/PreferenceForm.php @@ -211,8 +211,9 @@ class PreferenceForm extends Form } if (isset($formData['theme']) && $formData['theme'] !== StyleSheet::DEFAULT_THEME) { - $file = file_get_contents(StyleSheet::getThemeFile($formData['theme'])); - if (! preg_match(StyleSheet::REGEX_ALL_MODE_QUERY, $file)) { + $themeFile = StyleSheet::getThemeFile($formData['theme']); + $file = $themeFile !== null ? @file_get_contents($themeFile) : false; + if ($file && ! preg_match(StyleSheet::REGEX_ALL_MODE_QUERY, $file)) { $disabled = ['', 'light', 'system']; if (preg_match(StyleSheet::REGEX_AUTO_MODE_QUERY, $file)) { $value = 'system'; From fd4ab2babce7e981ddd698987fda5cf625daf2e8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 2 Nov 2021 15:09:52 +0100 Subject: [PATCH 2/2] StyleSheet: Handle missing themes gracefully --- library/Icinga/Web/StyleSheet.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index 0c4900f7d..94e01ad13 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -181,8 +181,8 @@ class StyleSheet $mode = 'none'; if ($user = Auth::getInstance()->getUser()) { - $file = $themePath !== null ? file_get_contents($themePath) : ''; - if ($file !== '' && ! preg_match(self::REGEX_ALL_MODE_QUERY, $file)) { + $file = $themePath !== null ? @file_get_contents($themePath) : ''; + if ($file && $file !== '' && ! preg_match(self::REGEX_ALL_MODE_QUERY, $file)) { if (preg_match(self::REGEX_AUTO_MODE_QUERY, $file)) { $mode = 'system'; }