Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-11-30 15:06:10 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-11-30 17:24:20 +0300
commit73787958d0946ba0f9f9c0f6fed335a8bed88c84 (patch)
treec98bd916d0e23700c488397992e7107d13b1d7e7 /apps/theming
parent0cc0d826a8cf47b978f693224fd84e361beb2b69 (diff)
Store scss variables under a different prefix for each theming config version
The main issue with using the general theming- prefix is that with APCu caching the cache is not shared between processes, so when trying to reset the cache through the CLI, e.g. when updating the theming config the old cache is never invalidated. Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming')
-rw-r--r--apps/theming/lib/ThemingDefaults.php5
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php5
2 files changed, 6 insertions, 4 deletions
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index 3fdbc1a61ae..ed231492962 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -281,13 +281,14 @@ class ThemingDefaults extends \OC_Defaults {
* @return array scss variables to overwrite
*/
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')) {
return $value;
}
$variables = [
- 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
+ 'theming-cachebuster' => "'" . $cacheBuster . "'",
'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'",
'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'",
'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'",
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index e5b6fb72db0..f024f73370e 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -640,9 +640,10 @@ class ThemingDefaultsTest extends TestCase {
}
public function testGetScssVariablesCached() {
+ $this->config->expects($this->any())->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('1');
$this->cacheFactory->expects($this->once())
->method('createDistributed')
- ->with('theming-')
+ ->with('theming-1-')
->willReturn($this->cache);
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(['foo'=>'bar']);
$this->assertEquals(['foo'=>'bar'], $this->template->getScssVariables());
@@ -664,7 +665,7 @@ class ThemingDefaultsTest extends TestCase {
$this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa');
$this->cacheFactory->expects($this->once())
->method('createDistributed')
- ->with('theming-')
+ ->with('theming-0-')
->willReturn($this->cache);
$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');