diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-11-06 11:26:53 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-11-06 11:31:36 +0100 |
commit | cd849db8be9bf7712ff216e81c3d134087be0eb1 (patch) | |
tree | b93c4c05cc83e40d476ccd611c61742b624c9634 /lib/private/Template | |
parent | 2c6bbe783a6ab0f75f9ad85d66d9b4511a7543be (diff) | |
download | nextcloud-server-cd849db8be9bf7712ff216e81c3d134087be0eb1.tar.gz nextcloud-server-cd849db8be9bf7712ff216e81c3d134087be0eb1.zip |
Avoid SCSS compilation if not needed
Now we do on each template load a compile with the SCSS variables to see
if they changed or not. However there is no real reason for this if the
variables didn't change.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Template')
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 225078ff6a4..1c6ca661839 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -283,8 +283,9 @@ class SCSSCacher { * @return bool */ private function variablesChanged(): bool { - $injectedVariables = $this->getInjectedVariables(); - if ($this->config->getAppValue('core', 'theming.variables') !== md5($injectedVariables)) { + $cachedVariables = $this->config->getAppValue('core', 'theming.variables', ''); + $injectedVariables = $this->getInjectedVariables($cachedVariables); + if ($cachedVariables !== md5($injectedVariables)) { $this->logger->debug('SCSSCacher::variablesChanged storedVariables: ' . json_encode($this->config->getAppValue('core', 'theming.variables')) . ' currentInjectedVariables: ' . json_encode($injectedVariables), ['app' => 'scss_cacher']); $this->config->setAppValue('core', 'theming.variables', md5($injectedVariables)); $this->resetCache(); @@ -411,7 +412,7 @@ class SCSSCacher { /** * @return string SCSS code for variables from OC_Defaults */ - private function getInjectedVariables(): string { + private function getInjectedVariables(string $cache = ''): string { if ($this->injectedVariables !== null) { return $this->injectedVariables; } @@ -420,6 +421,15 @@ class SCSSCacher { $variables .= '$' . $key . ': ' . $value . ' !default;'; } + /* + * If we are trying to return the same variables as that are cached + * Then there is no need to do the compile step + */ + if ($cache === md5($variables)) { + $this->injectedVariables = $variables; + return $variables; + } + // check for valid variables / otherwise fall back to defaults try { $scss = new Compiler(); |