Skip to content

Commit 4a2b72d

Browse files
authored
Merge pull request #24453 from nextcloud/backport/24449/stable20
[stable20] Store scss variables under a different prefix for each theming config version
2 parents 6916240 + 7d57b2c commit 4a2b72d

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

apps/theming/lib/ThemingDefaults.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,14 @@ public function getAndroidClientUrl() {
290290
* @return array scss variables to overwrite
291291
*/
292292
public function getScssVariables() {
293-
$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
293+
$cacheBuster = $this->config->getAppValue('theming', 'cachebuster', '0');
294+
$cache = $this->cacheFactory->createDistributed('theming-' . $cacheBuster . '-' . $this->urlGenerator->getBaseUrl());
294295
if ($value = $cache->get('getScssVariables')) {
295296
return $value;
296297
}
297298

298299
$variables = [
299-
'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
300+
'theming-cachebuster' => "'" . $cacheBuster . "'",
300301
'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'",
301302
'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'",
302303
'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'",

apps/theming/tests/ThemingDefaultsTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,10 @@ public function testGetLogoCustom() {
634634
}
635635

636636
public function testGetScssVariablesCached() {
637+
$this->config->expects($this->any())->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('1');
637638
$this->cacheFactory->expects($this->once())
638639
->method('createDistributed')
639-
->with('theming-')
640+
->with('theming-1-')
640641
->willReturn($this->cache);
641642
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(['foo'=>'bar']);
642643
$this->assertEquals(['foo'=>'bar'], $this->template->getScssVariables());
@@ -658,7 +659,7 @@ public function testGetScssVariables() {
658659
$this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa');
659660
$this->cacheFactory->expects($this->once())
660661
->method('createDistributed')
661-
->with('theming-')
662+
->with('theming-0-')
662663
->willReturn($this->cache);
663664
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null);
664665
$this->imageManager->expects($this->at(0))->method('getImageUrl')->with('logo')->willReturn('custom-logo?v=0');

0 commit comments

Comments
 (0)