diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-12-14 12:12:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-14 12:12:15 +0100 |
commit | b19b1379699cf7790a13575f27a05b2f6db14f6a (patch) | |
tree | 930b0146bea66d0e80522acf258929f03608e711 | |
parent | 1f108970c45c2269e68094ced1e9f13f1ac0f863 (diff) | |
parent | b8778b0d856ecde2c777f7d6f7b7971927217bce (diff) | |
download | nextcloud-server-b19b1379699cf7790a13575f27a05b2f6db14f6a.tar.gz nextcloud-server-b19b1379699cf7790a13575f27a05b2f6db14f6a.zip |
Merge pull request #7504 from nextcloud/shorter-css-prefixes
Reduce length of md5 in scss caching
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 4 | ||||
-rw-r--r-- | tests/lib/Template/SCSSCacherTest.php | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index cd69b8b63c3..8f6cb85a120 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -285,7 +285,7 @@ class SCSSCacher { $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; // OC\Route\Router:75 if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { - $subst = 'url(\'../../'.$webDir.'/$1\')'; + $subst = 'url(\'../../'.$webDir.'/$1\')'; } else { $subst = 'url(\'../../../'.$webDir.'/$1\')'; } @@ -313,6 +313,6 @@ class SCSSCacher { */ private function prependBaseurlPrefix($cssFile) { $frontendController = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); - return md5($this->urlGenerator->getBaseUrl() . $frontendController) . '-' . $cssFile; + return substr(md5($this->urlGenerator->getBaseUrl() . $frontendController), 0, 8) . '-' . $cssFile; } } diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 345972bb1af..3825bc44c59 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -88,7 +88,7 @@ class SCSSCacherTest extends \Test\TestCase { $fileDeps = $this->createMock(ISimpleFile::class); $gzfile = $this->createMock(ISimpleFile::class); - $filePrefix = md5('http://localhost/nextcloud') . '-'; + $filePrefix = substr(md5('http://localhost/nextcloud'), 0, 8) . '-'; $folder->method('getFile') ->will($this->returnCallback(function($path) use ($file, $gzfile, $filePrefix) { @@ -122,7 +122,7 @@ class SCSSCacherTest extends \Test\TestCase { $file->expects($this->any())->method('getSize')->willReturn(1); $fileDeps = $this->createMock(ISimpleFile::class); $gzfile = $this->createMock(ISimpleFile::class); - $filePrefix = md5('http://localhost/nextcloud') . '-'; + $filePrefix = substr(md5('http://localhost/nextcloud'), 0, 8) . '-'; $folder->method('getFile') ->will($this->returnCallback(function($path) use ($file, $gzfile, $filePrefix) { @@ -152,7 +152,7 @@ class SCSSCacherTest extends \Test\TestCase { $fileDeps = $this->createMock(ISimpleFile::class); $fileDeps->expects($this->any())->method('getSize')->willReturn(1); $gzFile = $this->createMock(ISimpleFile::class); - $filePrefix = md5('http://localhost/nextcloud') . '-'; + $filePrefix = substr(md5('http://localhost/nextcloud'), 0, 8) . '-'; $folder->method('getFile') ->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile, $filePrefix) { @@ -185,7 +185,7 @@ class SCSSCacherTest extends \Test\TestCase { $fileDeps->expects($this->any())->method('getSize')->willReturn(1); $gzFile = $this->createMock(ISimpleFile::class); - $filePrefix = md5('http://localhost/nextcloud') . '-'; + $filePrefix = substr(md5('http://localhost/nextcloud'), 0, 8) . '-'; $folder->method('getFile') ->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile, $filePrefix) { if ($name === $filePrefix.'styles.css') { @@ -385,7 +385,7 @@ class SCSSCacherTest extends \Test\TestCase { $this->urlGenerator->expects($this->once()) ->method('linkToRoute') ->with('core.Css.getCss', [ - 'fileName' => md5('http://localhost/nextcloud') . '-styles.css', + 'fileName' => substr(md5('http://localhost/nextcloud'), 0, 8) . '-styles.css', 'appName' => $appName ]) ->willReturn(\OC::$WEBROOT . $result); |