$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();
$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);
$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);
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());
+ }
}
* 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;
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;
}
/**
$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;
+ }
}
* @since 8.0.0
*/
public function linkToDocs($key);
+
+ /**
+ * @return string base url of the current request
+ * @since 13.0.0
+ */
+ public function getBaseUrl();
}