diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index a552122b35801..19eb06acf0f16 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -272,6 +272,13 @@ private function isCached(string $fileNameCSS, string $app) { private function variablesChanged(): bool { $cachedVariables = $this->config->getAppValue('core', 'theming.variables', ''); $injectedVariables = $this->getInjectedVariables($cachedVariables); + + if (empty($injectedVariables)) { + // There might be cases where the no variables could be fetched + // Stay with the old ones in that case ot avoid cache reset that is not needed + return false; + } + if ($cachedVariables !== md5($injectedVariables)) { $this->logger->debug('SCSSCacher::variablesChanged storedVariables: ' . json_encode($this->config->getAppValue('core', 'theming.variables')) . ' currentInjectedVariables: ' . json_encode($injectedVariables), ['app' => 'scss_cacher']); $this->config->setAppValue('core', 'theming.variables', md5($injectedVariables)); diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index f7b7b3bb6d356..4e94de0e8b28c 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -101,7 +101,7 @@ protected function setUp(): void { ); $this->themingDefaults = $this->createMock(ThemingDefaults::class); - $this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn([]); + $this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn(['color-primary' => '#745bca']); $iconsFile = $this->createMock(ISimpleFile::class); $this->iconsCacher->expects($this->any())