Merge pull request #7504 from nextcloud/shorter-css-prefixes

Reduce length of md5 in scss caching
This commit is contained in:
Morris Jobke 2017-12-14 12:12:15 +01:00 committed by GitHub
commit b19b137969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -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);