diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-03-08 21:12:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-08 21:12:54 +0100 |
commit | 7a7c350a2d284f418a1e52d80bfaaaaff12330b0 (patch) | |
tree | 6081899002de29347a16f585425c71cb69c3c9d5 /lib/private | |
parent | 7e374200c4eef0e2b61076857acaed5fcdee286a (diff) | |
parent | 573b94076103b2f3740ee243a2089279600523d4 (diff) | |
download | nextcloud-server-7a7c350a2d284f418a1e52d80bfaaaaff12330b0.tar.gz nextcloud-server-7a7c350a2d284f418a1e52d80bfaaaaff12330b0.zip |
Merge pull request #8716 from nextcloud/fix-cache-prefixing
Remove base url from global cache prefix
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Server.php | 6 | ||||
-rw-r--r-- | lib/private/Template/JSCombiner.php | 13 | ||||
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 13 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 8 |
4 files changed, 22 insertions, 18 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php index d586bab15b9..e0bd21b0358 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -498,7 +498,7 @@ class Server extends ServerContainer implements IServerContainer { $version = implode(',', $v); $instanceId = \OC_Util::getInstanceId(); $path = \OC::$SERVERROOT; - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl()); + $prefix = md5($instanceId . '-' . $version . '-' . $path); return new \OC\Memcache\Factory($prefix, $c->getLogger(), $config->getSystemValue('memcache.local', null), $config->getSystemValue('memcache.distributed', null), @@ -965,7 +965,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getConfig(), $c->getThemingDefaults(), \OC::$SERVERROOT, - $cacheFactory->createDistributed('SCSS') + $this->getMemCacheFactory() ); }); $this->registerService(JSCombiner::class, function (Server $c) { @@ -974,7 +974,7 @@ class Server extends ServerContainer implements IServerContainer { return new JSCombiner( $c->getAppDataDir('js'), $c->getURLGenerator(), - $cacheFactory->createDistributed('JS'), + $this->getMemCacheFactory(), $c->getSystemConfig(), $c->getLogger() ); diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php index bc548c22fd0..93683753899 100644 --- a/lib/private/Template/JSCombiner.php +++ b/lib/private/Template/JSCombiner.php @@ -30,6 +30,7 @@ use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFolder; +use OCP\ICacheFactory; use OCP\ILogger; use OCP\IURLGenerator; @@ -50,21 +51,25 @@ class JSCombiner { /** @var ILogger */ protected $logger; + /** @var ICacheFactory */ + private $cacheFactory; + /** * @param IAppData $appData * @param IURLGenerator $urlGenerator - * @param ICache $depsCache + * @param ICacheFactory $cacheFactory * @param SystemConfig $config * @param ILogger $logger */ public function __construct(IAppData $appData, IURLGenerator $urlGenerator, - ICache $depsCache, + ICacheFactory $cacheFactory, SystemConfig $config, ILogger $logger) { $this->appData = $appData; $this->urlGenerator = $urlGenerator; - $this->depsCache = $depsCache; + $this->cacheFactory = $cacheFactory; + $this->depsCache = $this->cacheFactory->createDistributed('JS-' . md5($this->urlGenerator->getBaseUrl())); $this->config = $config; $this->logger = $logger; } @@ -243,7 +248,7 @@ class JSCombiner { * @throws NotFoundException */ public function resetCache() { - $this->depsCache->clear(); + $this->cacheFactory->createDistributed('JS-')->clear(); $appDirectory = $this->appData->getDirectoryListing(); foreach ($appDirectory as $folder) { foreach ($folder->getDirectoryListing() as $file) { diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 433d5e5d0bf..0f5be9643b4 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -39,6 +39,7 @@ use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\ILogger; use OCP\IURLGenerator; @@ -69,6 +70,9 @@ class SCSSCacher { /** @var null|string */ private $injectedVariables; + /** @var ICacheFactory */ + private $cacheFactory; + /** * @param ILogger $logger * @param Factory $appDataFactory @@ -76,7 +80,7 @@ class SCSSCacher { * @param IConfig $config * @param \OC_Defaults $defaults * @param string $serverRoot - * @param ICache $depsCache + * @param ICacheFactory $cacheFactory */ public function __construct(ILogger $logger, Factory $appDataFactory, @@ -84,14 +88,15 @@ class SCSSCacher { IConfig $config, \OC_Defaults $defaults, $serverRoot, - ICache $depsCache) { + ICacheFactory $cacheFactory) { $this->logger = $logger; $this->appData = $appDataFactory->get('css'); $this->urlGenerator = $urlGenerator; $this->config = $config; $this->defaults = $defaults; $this->serverRoot = $serverRoot; - $this->depsCache = $depsCache; + $this->cacheFactory = $cacheFactory; + $this->depsCache = $cacheFactory->createDistributed('SCSS-' . md5($this->urlGenerator->getBaseUrl())); } /** @@ -263,7 +268,7 @@ class SCSSCacher { */ public function resetCache() { $this->injectedVariables = null; - $this->depsCache->clear(); + $this->cacheFactory->createDistributed('SCSS-')->clear(); $appDirectory = $this->appData->getDirectoryListing(); foreach ($appDirectory as $folder) { foreach ($folder->getDirectoryListing() as $file) { diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 0f2eb48bef3..c378396c727 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -306,13 +306,7 @@ class TemplateLayout extends \OC_Template { $theme, array( \OC::$SERVERROOT => \OC::$WEBROOT ), array( \OC::$SERVERROOT => \OC::$WEBROOT ), - new JSCombiner( - \OC::$server->getAppDataDir('js'), - \OC::$server->getURLGenerator(), - \OC::$server->getMemCacheFactory()->createDistributed('JS'), - \OC::$server->getSystemConfig(), - \OC::$server->getLogger() - ) + \OC::$server->query(JSCombiner::class) ); $locator->find($scripts); return $locator->getResources(); |