Make cache and scss caching depend on the baseUrl
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
f02575db94
commit
3801c3aa3f
|
@ -433,7 +433,13 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$this->registerAlias('UserCache', \OCP\ICache::class);
|
||||
|
||||
$this->registerService(Factory::class, function (Server $c) {
|
||||
$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
|
||||
'\\OC\\Memcache\\ArrayCache',
|
||||
'\\OC\\Memcache\\ArrayCache',
|
||||
'\\OC\\Memcache\\ArrayCache'
|
||||
);
|
||||
$config = $c->getConfig();
|
||||
$urlGenerator = new URLGenerator($config, $arrayCacheFactory);
|
||||
|
||||
if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
|
||||
$v = \OC_App::getAppVersions();
|
||||
|
@ -441,19 +447,15 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$version = implode(',', $v);
|
||||
$instanceId = \OC_Util::getInstanceId();
|
||||
$path = \OC::$SERVERROOT;
|
||||
$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
|
||||
$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
|
||||
return new \OC\Memcache\Factory($prefix, $c->getLogger(),
|
||||
$config->getSystemValue('memcache.local', null),
|
||||
$config->getSystemValue('memcache.distributed', null),
|
||||
$config->getSystemValue('memcache.locking', null)
|
||||
);
|
||||
}
|
||||
return $arrayCacheFactory;
|
||||
|
||||
return new \OC\Memcache\Factory('', $c->getLogger(),
|
||||
'\\OC\\Memcache\\ArrayCache',
|
||||
'\\OC\\Memcache\\ArrayCache',
|
||||
'\\OC\\Memcache\\ArrayCache'
|
||||
);
|
||||
});
|
||||
$this->registerAlias('MemCacheFactory', Factory::class);
|
||||
$this->registerAlias(ICacheFactory::class, Factory::class);
|
||||
|
|
|
@ -92,7 +92,7 @@ class SCSSCacher {
|
|||
$path = explode('/', $root . '/' . $file);
|
||||
|
||||
$fileNameSCSS = array_pop($path);
|
||||
$fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS);
|
||||
$fileNameCSS = $this->getBaseUrlHash() . '-' . str_replace('.scss', '.css', $fileNameSCSS);
|
||||
|
||||
$path = implode('/', $path);
|
||||
|
||||
|
@ -292,8 +292,12 @@ class SCSSCacher {
|
|||
public function getCachedSCSS($appName, $fileName) {
|
||||
$tmpfileLoc = explode('/', $fileName);
|
||||
$fileName = array_pop($tmpfileLoc);
|
||||
$fileName = str_replace('.scss', '.css', $fileName);
|
||||
$fileName = $this->getBaseUrlHash() . '-' . str_replace('.scss', '.css', $fileName);
|
||||
|
||||
return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1);
|
||||
}
|
||||
|
||||
private function getBaseUrlHash() {
|
||||
return md5($this->urlGenerator->getBaseUrl());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ class URLGenerator implements IURLGenerator {
|
|||
* Returns the path to the image.
|
||||
*/
|
||||
public function imagePath($app, $image) {
|
||||
$cache = $this->cacheFactory->create('imagePath');
|
||||
$cache = $this->cacheFactory->create('imagePath-'.md5($this->getBaseUrl()).'-');
|
||||
$cacheKey = $app.'-'.$image;
|
||||
if($key = $cache->get($cacheKey)) {
|
||||
return $key;
|
||||
|
@ -223,14 +223,12 @@ class URLGenerator implements IURLGenerator {
|
|||
if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
|
||||
return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
|
||||
}
|
||||
|
||||
// The ownCloud web root can already be prepended.
|
||||
$webRoot = substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT
|
||||
? ''
|
||||
: \OC::$WEBROOT;
|
||||
if(substr($url, 0, strlen(\OC::$WEBROOT)) === \OC::$WEBROOT) {
|
||||
$url = substr($url, strlen(\OC::$WEBROOT));
|
||||
}
|
||||
|
||||
$request = \OC::$server->getRequest();
|
||||
return $request->getServerProtocol() . '://' . $request->getServerHost() . $webRoot . $separator . $url;
|
||||
return $this->getBaseUrl() . $separator . $url;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,4 +239,12 @@ class URLGenerator implements IURLGenerator {
|
|||
$theme = \OC::$server->getThemingDefaults();
|
||||
return $theme->buildDocLinkToKey($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string base url of the current request
|
||||
*/
|
||||
public function getBaseUrl() {
|
||||
$request = \OC::$server->getRequest();
|
||||
return $request->getServerProtocol() . '://' . $request->getServerHost() . \OC::$WEBROOT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,4 +91,10 @@ interface IURLGenerator {
|
|||
* @since 8.0.0
|
||||
*/
|
||||
public function linkToDocs($key);
|
||||
|
||||
/**
|
||||
* @return string base url of the current request
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getBaseUrl();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue