Merge pull request #24452 from nextcloud/backport/24449/stable19

[stable19] Store scss variables under a different prefix for each theming config version
This commit is contained in:
Morris Jobke 2020-11-30 16:54:28 +01:00 committed by GitHub
commit 4d341334c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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') . "'",

View File

@ -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');