Let SCSS cleanup only run once (#17543)

Let SCSS cleanup only run once
This commit is contained in:
John Molakvoæ 2019-10-17 10:03:08 +02:00 committed by GitHub
commit bd5189f29f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -117,7 +117,7 @@ class SCSSCacher {
$this->serverRoot = $serverRoot; $this->serverRoot = $serverRoot;
$this->cacheFactory = $cacheFactory; $this->cacheFactory = $cacheFactory;
$this->depsCache = $cacheFactory->createDistributed('SCSS-deps-' . md5($this->urlGenerator->getBaseUrl())); $this->depsCache = $cacheFactory->createDistributed('SCSS-deps-' . md5($this->urlGenerator->getBaseUrl()));
$this->isCachedCache = $cacheFactory->createLocal('SCSS-cached-' . md5($this->urlGenerator->getBaseUrl())); $this->isCachedCache = $cacheFactory->createDistributed('SCSS-cached-' . md5($this->urlGenerator->getBaseUrl()));
$lockingCache = $cacheFactory->createDistributed('SCSS-locks-' . md5($this->urlGenerator->getBaseUrl())); $lockingCache = $cacheFactory->createDistributed('SCSS-locks-' . md5($this->urlGenerator->getBaseUrl()));
if (!($lockingCache instanceof IMemcache)) { if (!($lockingCache instanceof IMemcache)) {
$lockingCache = new NullCache(); $lockingCache = new NullCache();
@ -269,8 +269,8 @@ class SCSSCacher {
private function variablesChanged(): bool { private function variablesChanged(): bool {
$injectedVariables = $this->getInjectedVariables(); $injectedVariables = $this->getInjectedVariables();
if ($this->config->getAppValue('core', 'theming.variables') !== md5($injectedVariables)) { if ($this->config->getAppValue('core', 'theming.variables') !== md5($injectedVariables)) {
$this->resetCache();
$this->config->setAppValue('core', 'theming.variables', md5($injectedVariables)); $this->config->setAppValue('core', 'theming.variables', md5($injectedVariables));
$this->resetCache();
return true; return true;
} }
return false; return false;
@ -364,6 +364,9 @@ class SCSSCacher {
* We need to regenerate all files when variables change * We need to regenerate all files when variables change
*/ */
public function resetCache() { public function resetCache() {
if (!$this->lockingCache->add('resetCache', 'locked!', 120)) {
return;
}
$this->injectedVariables = null; $this->injectedVariables = null;
// do not clear locks // do not clear locks
@ -381,6 +384,7 @@ class SCSSCacher {
} }
} }
$this->logger->debug('SCSSCacher: css cache cleared!'); $this->logger->debug('SCSSCacher: css cache cleared!');
$this->lockingCache->remove('resetCache');
} }
/** /**