Skip to content
Snippets Groups Projects
Unverified Commit deb70737 authored by Morris Jobke's avatar Morris Jobke Committed by GitHub
Browse files

Merge pull request #24449 from nextcloud/bugfix/noid/theming-scss-apcu

Store scss variables under a different prefix for each theming config version
parents bff1f045 22e26a7f
No related branches found
No related tags found
No related merge requests found
...@@ -290,13 +290,14 @@ class ThemingDefaults extends \OC_Defaults { ...@@ -290,13 +290,14 @@ class ThemingDefaults extends \OC_Defaults {
* @return array scss variables to overwrite * @return array scss variables to overwrite
*/ */
public function getScssVariables() { public function getScssVariables() {
$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); $cacheBuster = $this->config->getAppValue('theming', 'cachebuster', '0');
$cache = $this->cacheFactory->createDistributed('theming-' . $cacheBuster . '-' . $this->urlGenerator->getBaseUrl());
if ($value = $cache->get('getScssVariables')) { if ($value = $cache->get('getScssVariables')) {
return $value; return $value;
} }
$variables = [ $variables = [
'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", 'theming-cachebuster' => "'" . $cacheBuster . "'",
'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'", 'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'",
'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'", 'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'",
'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'", 'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'",
......
...@@ -634,9 +634,10 @@ class ThemingDefaultsTest extends TestCase { ...@@ -634,9 +634,10 @@ class ThemingDefaultsTest extends TestCase {
} }
public function testGetScssVariablesCached() { public function testGetScssVariablesCached() {
$this->config->expects($this->any())->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('1');
$this->cacheFactory->expects($this->once()) $this->cacheFactory->expects($this->once())
->method('createDistributed') ->method('createDistributed')
->with('theming-') ->with('theming-1-')
->willReturn($this->cache); ->willReturn($this->cache);
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(['foo' => 'bar']); $this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(['foo' => 'bar']);
$this->assertEquals(['foo' => 'bar'], $this->template->getScssVariables()); $this->assertEquals(['foo' => 'bar'], $this->template->getScssVariables());
...@@ -658,7 +659,7 @@ class ThemingDefaultsTest extends TestCase { ...@@ -658,7 +659,7 @@ class ThemingDefaultsTest extends TestCase {
$this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa'); $this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa');
$this->cacheFactory->expects($this->once()) $this->cacheFactory->expects($this->once())
->method('createDistributed') ->method('createDistributed')
->with('theming-') ->with('theming-0-')
->willReturn($this->cache); ->willReturn($this->cache);
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null); $this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null);
$this->imageManager->expects($this->at(0))->method('getImageUrl')->with('logo')->willReturn('custom-logo?v=0'); $this->imageManager->expects($this->at(0))->method('getImageUrl')->with('logo')->willReturn('custom-logo?v=0');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment