diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-27 10:21:54 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-28 08:33:46 +0200 |
commit | 1d7b14dfb19603867cbcab27a42ca7cf4047f3c8 (patch) | |
tree | 23735dcee83c3c88659bcd17a29165b02e079c5f /lib/private/Template | |
parent | 7b4e51dbc71c1112663b65c08b14eed44dcb50a3 (diff) | |
download | nextcloud-server-1d7b14dfb19603867cbcab27a42ca7cf4047f3c8.tar.gz nextcloud-server-1d7b14dfb19603867cbcab27a42ca7cf4047f3c8.zip |
Use app version to generate scss filename
Fixed scsscacher tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private/Template')
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 0f5be9643b4..6fb9d11953b 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -112,7 +112,7 @@ class SCSSCacher { $path = explode('/', $root . '/' . $file); $fileNameSCSS = array_pop($path); - $fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)); + $fileNameCSS = $this->prependVersionPrefix($this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)), $app); $path = implode('/', $path); $webDir = $this->getWebDir($path, $app, $this->serverRoot, \OC::$WEBROOT); @@ -138,7 +138,8 @@ class SCSSCacher { */ public function getCachedCSS(string $appName, string $fileName): ISimpleFile { $folder = $this->appData->getFolder($appName); - return $folder->getFile($this->prependBaseurlPrefix($fileName)); + $cachedFileName = $this->prependVersionPrefix($this->prependBaseurlPrefix($fileName), $appName); + return $folder->getFile($cachedFileName); } /** @@ -322,19 +323,34 @@ class SCSSCacher { public function getCachedSCSS(string $appName, string $fileName): string { $tmpfileLoc = explode('/', $fileName); $fileName = array_pop($tmpfileLoc); - $fileName = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileName)); + $fileName = $this->prependVersionPrefix($this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileName)), $appName); return substr($this->urlGenerator->linkToRoute('core.Css.getCss', ['fileName' => $fileName, 'appName' => $appName]), strlen(\OC::$WEBROOT) + 1); } /** * Prepend hashed base url to the css file - * @param string$cssFile + * @param string $cssFile * @return string */ private function prependBaseurlPrefix(string $cssFile): string { $frontendController = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); - return substr(md5($this->urlGenerator->getBaseUrl() . $frontendController), 0, 8) . '-' . $cssFile; + return substr(md5($this->urlGenerator->getBaseUrl() . $frontendController), 0, 4) . '-' . $cssFile; + } + + /** + * Prepend hashed app version hash + * @param string $cssFile + * @param string $appId + * @return string + */ + private function prependVersionPrefix(string $cssFile, string $appId): string { + $appVersion = \OC_App::getAppVersion($appId); + if ($appVersion !== '0') { + return substr(md5($appVersion), 0, 4) . '-' . $cssFile; + } + $coreVersion = \OC_Util::getVersionString(); + return substr(md5($coreVersion), 0, 4) . '-' . $cssFile; } /** |