Skip to content

Commit a04ed00

Browse files
committed
fix: Avoid resetting scss cacher when no variables are found
Signed-off-by: Julius Härtl <[email protected]>
1 parent 1982668 commit a04ed00

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/private/Template/SCSSCacher.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ private function isCached(string $fileNameCSS, string $app) {
272272
private function variablesChanged(): bool {
273273
$cachedVariables = $this->config->getAppValue('core', 'theming.variables', '');
274274
$injectedVariables = $this->getInjectedVariables($cachedVariables);
275+
276+
if (empty($injectedVariables)) {
277+
// There might be cases where the no variables could be fetched
278+
// Stay with the old ones in that case ot avoid cache reset that is not needed
279+
return false;
280+
}
281+
275282
if ($cachedVariables !== md5($injectedVariables)) {
276283
$this->logger->debug('SCSSCacher::variablesChanged storedVariables: ' . json_encode($this->config->getAppValue('core', 'theming.variables')) . ' currentInjectedVariables: ' . json_encode($injectedVariables), ['app' => 'scss_cacher']);
277284
$this->config->setAppValue('core', 'theming.variables', md5($injectedVariables));

tests/lib/Template/SCSSCacherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function setUp(): void {
101101
);
102102

103103
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
104-
$this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn([]);
104+
$this->themingDefaults->expects($this->any())->method('getScssVariables')->willReturn(['color-primary' => '#745bca']);
105105

106106
$iconsFile = $this->createMock(ISimpleFile::class);
107107
$this->iconsCacher->expects($this->any())

0 commit comments

Comments
 (0)