From f2d5927ea3bbd2ccd7152bc3638b25b5e577f94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 14 Dec 2017 08:51:53 +0100 Subject: [PATCH 1/3] Reduce length of md5 in scss caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Template/SCSSCacher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 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; } } From 158f442f4f99a4c273270f2a188657a44d493061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 14 Dec 2017 11:28:59 +0100 Subject: [PATCH 2/3] Test fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- tests/lib/Template/SCSSCacherTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 345972bb1af..5ee9af2a409 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -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); From b8778b0d856ecde2c777f7d6f7b7971927217bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 14 Dec 2017 11:32:53 +0100 Subject: [PATCH 3/3] Test fixes 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- tests/lib/Template/SCSSCacherTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 5ee9af2a409..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) {