@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | $this->defaults = $defaults; |
122 | 122 | $this->serverRoot = $serverRoot; |
123 | 123 | $this->cacheFactory = $cacheFactory; |
124 | - $this->depsCache = $cacheFactory->createDistributed('SCSS-deps-' . md5($this->urlGenerator->getBaseUrl())); |
|
125 | - $this->isCachedCache = $cacheFactory->createDistributed('SCSS-cached-' . md5($this->urlGenerator->getBaseUrl())); |
|
126 | - $lockingCache = $cacheFactory->createDistributed('SCSS-locks-' . md5($this->urlGenerator->getBaseUrl())); |
|
124 | + $this->depsCache = $cacheFactory->createDistributed('SCSS-deps-'.md5($this->urlGenerator->getBaseUrl())); |
|
125 | + $this->isCachedCache = $cacheFactory->createDistributed('SCSS-cached-'.md5($this->urlGenerator->getBaseUrl())); |
|
126 | + $lockingCache = $cacheFactory->createDistributed('SCSS-locks-'.md5($this->urlGenerator->getBaseUrl())); |
|
127 | 127 | if (!($lockingCache instanceof IMemcache)) { |
128 | 128 | $lockingCache = new NullCache(); |
129 | 129 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @throws NotPermittedException |
144 | 144 | */ |
145 | 145 | public function process(string $root, string $file, string $app): bool { |
146 | - $path = explode('/', $root . '/' . $file); |
|
146 | + $path = explode('/', $root.'/'.$file); |
|
147 | 147 | |
148 | 148 | $fileNameSCSS = array_pop($path); |
149 | 149 | $fileNameCSS = $this->prependVersionPrefix($this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)), $app); |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | $folder = $this->appData->newFolder($app); |
165 | 165 | } |
166 | 166 | |
167 | - $lockKey = $webDir . '/' . $fileNameSCSS; |
|
167 | + $lockKey = $webDir.'/'.$fileNameSCSS; |
|
168 | 168 | |
169 | 169 | if (!$this->lockingCache->add($lockKey, 'locked!', 120)) { |
170 | - $this->logger->debug('SCSSCacher::process could not get lock for ' . $lockKey . ' and will wait 10 seconds for cached file to be available', ['app' => 'scss_cacher']); |
|
170 | + $this->logger->debug('SCSSCacher::process could not get lock for '.$lockKey.' and will wait 10 seconds for cached file to be available', ['app' => 'scss_cacher']); |
|
171 | 171 | $retry = 0; |
172 | 172 | sleep(1); |
173 | 173 | while ($retry < 10) { |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | sleep(1); |
182 | 182 | $retry++; |
183 | 183 | } |
184 | - $this->logger->debug('SCSSCacher::process Giving up scss caching for ' . $lockKey, ['app' => 'scss_cacher']); |
|
184 | + $this->logger->debug('SCSSCacher::process Giving up scss caching for '.$lockKey, ['app' => 'scss_cacher']); |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | |
188 | - $this->logger->debug('SCSSCacher::process Lock acquired for ' . $lockKey, ['app' => 'scss_cacher']); |
|
188 | + $this->logger->debug('SCSSCacher::process Lock acquired for '.$lockKey, ['app' => 'scss_cacher']); |
|
189 | 189 | try { |
190 | 190 | $cached = $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); |
191 | 191 | } catch (\Exception $e) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | // Cleaning lock |
197 | 197 | $this->lockingCache->remove($lockKey); |
198 | - $this->logger->debug('SCSSCacher::process Lock removed for ' . $lockKey, ['app' => 'scss_cacher']); |
|
198 | + $this->logger->debug('SCSSCacher::process Lock removed for '.$lockKey, ['app' => 'scss_cacher']); |
|
199 | 199 | |
200 | 200 | // Inject icons vars css if any |
201 | 201 | if ($this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return boolean |
225 | 225 | */ |
226 | 226 | private function isCached(string $fileNameCSS, string $app) { |
227 | - $key = $this->config->getSystemValue('version') . '/' . $app . '/' . $fileNameCSS; |
|
227 | + $key = $this->config->getSystemValue('version').'/'.$app.'/'.$fileNameCSS; |
|
228 | 228 | |
229 | 229 | // If the file mtime is more recent than our cached one, |
230 | 230 | // let's consider the file is properly cached |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | try { |
249 | 249 | $cachedFile = $folder->getFile($fileNameCSS); |
250 | 250 | if ($cachedFile->getSize() > 0) { |
251 | - $depFileName = $fileNameCSS . '.deps'; |
|
252 | - $deps = $this->depsCache->get($folder->getName() . '-' . $depFileName); |
|
251 | + $depFileName = $fileNameCSS.'.deps'; |
|
252 | + $deps = $this->depsCache->get($folder->getName().'-'.$depFileName); |
|
253 | 253 | if ($deps === null) { |
254 | 254 | $depFile = $folder->getFile($depFileName); |
255 | 255 | $deps = $depFile->getContent(); |
256 | 256 | // Set to memcache for next run |
257 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
257 | + $this->depsCache->set($folder->getName().'-'.$depFileName, $deps); |
|
258 | 258 | } |
259 | 259 | $deps = json_decode($deps, true); |
260 | 260 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $this->logger->debug("SCSSCacher::isCached $fileNameCSS is not considered as cached cacheValue: $cacheValue", ['app' => 'scss_cacher']); |
274 | 274 | return false; |
275 | 275 | } catch (NotFoundException $e) { |
276 | - $this->logger->debug("SCSSCacher::isCached NotFoundException " . $e->getMessage(), ['app' => 'scss_cacher']); |
|
276 | + $this->logger->debug("SCSSCacher::isCached NotFoundException ".$e->getMessage(), ['app' => 'scss_cacher']); |
|
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $cachedVariables = $this->config->getAppValue('core', 'theming.variables', ''); |
287 | 287 | $injectedVariables = $this->getInjectedVariables($cachedVariables); |
288 | 288 | if ($cachedVariables !== md5($injectedVariables)) { |
289 | - $this->logger->debug('SCSSCacher::variablesChanged storedVariables: ' . json_encode($this->config->getAppValue('core', 'theming.variables')) . ' currentInjectedVariables: ' . json_encode($injectedVariables), ['app' => 'scss_cacher']); |
|
289 | + $this->logger->debug('SCSSCacher::variablesChanged storedVariables: '.json_encode($this->config->getAppValue('core', 'theming.variables')).' currentInjectedVariables: '.json_encode($injectedVariables), ['app' => 'scss_cacher']); |
|
290 | 290 | $this->config->setAppValue('core', 'theming.variables', md5($injectedVariables)); |
291 | 291 | $this->resetCache(); |
292 | 292 | return true; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | $scss = new Compiler(); |
310 | 310 | $scss->setImportPaths([ |
311 | 311 | $path, |
312 | - $this->serverRoot . '/core/css/' |
|
312 | + $this->serverRoot.'/core/css/' |
|
313 | 313 | ]); |
314 | 314 | |
315 | 315 | // Continue after throw |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $cachedfile = $folder->newFile($fileNameCSS); |
330 | 330 | } |
331 | 331 | |
332 | - $depFileName = $fileNameCSS . '.deps'; |
|
332 | + $depFileName = $fileNameCSS.'.deps'; |
|
333 | 333 | try { |
334 | 334 | $depFile = $folder->getFile($depFileName); |
335 | 335 | } catch (NotFoundException $e) { |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | // Compile |
340 | 340 | try { |
341 | 341 | $compiledScss = $scss->compile( |
342 | - '$webroot: \'' . $this->getRoutePrefix() . '\';' . |
|
343 | - $this->getInjectedVariables() . |
|
344 | - '@import "variables.scss";' . |
|
345 | - '@import "functions.scss";' . |
|
346 | - '@import "' . $fileNameSCSS . '";'); |
|
342 | + '$webroot: \''.$this->getRoutePrefix().'\';'. |
|
343 | + $this->getInjectedVariables(). |
|
344 | + '@import "variables.scss";'. |
|
345 | + '@import "functions.scss";'. |
|
346 | + '@import "'.$fileNameSCSS.'";'); |
|
347 | 347 | } catch (ParserException $e) { |
348 | 348 | $this->logger->logException($e, ['app' => 'scss_cacher']); |
349 | 349 | |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | |
356 | 356 | // Gzip file |
357 | 357 | try { |
358 | - $gzipFile = $folder->getFile($fileNameCSS . '.gzip'); # Safari doesn't like .gz |
|
358 | + $gzipFile = $folder->getFile($fileNameCSS.'.gzip'); # Safari doesn't like .gz |
|
359 | 359 | } catch (NotFoundException $e) { |
360 | - $gzipFile = $folder->newFile($fileNameCSS . '.gzip'); # Safari doesn't like .gz |
|
360 | + $gzipFile = $folder->newFile($fileNameCSS.'.gzip'); # Safari doesn't like .gz |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | try { |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | $cachedfile->putContent($data); |
366 | 366 | $deps = json_encode($scss->getParsedFiles()); |
367 | 367 | $depFile->putContent($deps); |
368 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
368 | + $this->depsCache->set($folder->getName().'-'.$depFileName, $deps); |
|
369 | 369 | $gzipFile->putContent(gzencode($data, 9)); |
370 | - $this->logger->debug('SCSSCacher::cache ' . $webDir . '/' . $fileNameSCSS . ' compiled and successfully cached', ['app' => 'scss_cacher']); |
|
370 | + $this->logger->debug('SCSSCacher::cache '.$webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'scss_cacher']); |
|
371 | 371 | |
372 | 372 | return true; |
373 | 373 | } catch (NotPermittedException $e) { |
374 | - $this->logger->error('SCSSCacher::cache unable to cache: ' . $fileNameSCSS, ['app' => 'scss_cacher']); |
|
374 | + $this->logger->error('SCSSCacher::cache unable to cache: '.$fileNameSCSS, ['app' => 'scss_cacher']); |
|
375 | 375 | |
376 | 376 | return false; |
377 | 377 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | try { |
401 | 401 | $file->delete(); |
402 | 402 | } catch (NotPermittedException $e) { |
403 | - $this->logger->logException($e, ['message' => 'SCSSCacher::resetCache unable to delete file: ' . $file->getName(), 'app' => 'scss_cacher']); |
|
403 | + $this->logger->logException($e, ['message' => 'SCSSCacher::resetCache unable to delete file: '.$file->getName(), 'app' => 'scss_cacher']); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | } |
419 | 419 | $variables = ''; |
420 | 420 | foreach ($this->defaults->getScssVariables() as $key => $value) { |
421 | - $variables .= '$' . $key . ': ' . $value . ' !default;'; |
|
421 | + $variables .= '$'.$key.': '.$value.' !default;'; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /* |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | */ |
451 | 451 | private function rebaseUrls(string $css, string $webDir): string { |
452 | 452 | $re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x'; |
453 | - $subst = 'url(\'' . $webDir . '/$1\')'; |
|
453 | + $subst = 'url(\''.$webDir.'/$1\')'; |
|
454 | 454 | |
455 | 455 | return preg_replace($re, $subst, $css); |
456 | 456 | } |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | * @return string |
480 | 480 | */ |
481 | 481 | private function prependBaseurlPrefix(string $cssFile): string { |
482 | - return substr(md5($this->urlGenerator->getBaseUrl() . $this->getRoutePrefix()), 0, 4) . '-' . $cssFile; |
|
482 | + return substr(md5($this->urlGenerator->getBaseUrl().$this->getRoutePrefix()), 0, 4).'-'.$cssFile; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | private function getRoutePrefix() { |
486 | 486 | $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
487 | - $prefix = \OC::$WEBROOT . '/index.php'; |
|
487 | + $prefix = \OC::$WEBROOT.'/index.php'; |
|
488 | 488 | if ($frontControllerActive) { |
489 | 489 | $prefix = \OC::$WEBROOT; |
490 | 490 | } |
@@ -500,11 +500,11 @@ discard block |
||
500 | 500 | private function prependVersionPrefix(string $cssFile, string $appId): string { |
501 | 501 | $appVersion = \OC_App::getAppVersion($appId); |
502 | 502 | if ($appVersion !== '0') { |
503 | - return substr(md5($appVersion), 0, 4) . '-' . $cssFile; |
|
503 | + return substr(md5($appVersion), 0, 4).'-'.$cssFile; |
|
504 | 504 | } |
505 | 505 | $coreVersion = \OC_Util::getVersionString(); |
506 | 506 | |
507 | - return substr(md5($coreVersion), 0, 4) . '-' . $cssFile; |
|
507 | + return substr(md5($coreVersion), 0, 4).'-'.$cssFile; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -522,10 +522,10 @@ discard block |
||
522 | 522 | $appDirectoryPath = explode($appName, $path)[1]; |
523 | 523 | // Remove the webroot |
524 | 524 | |
525 | - return str_replace($webRoot, '', $appWebPath . $appDirectoryPath); |
|
525 | + return str_replace($webRoot, '', $appWebPath.$appDirectoryPath); |
|
526 | 526 | } |
527 | 527 | |
528 | - return $webRoot . substr($path, strlen($serverRoot)); |
|
528 | + return $webRoot.substr($path, strlen($serverRoot)); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |