From 63e261b4446996d9ba42f09b1c1b17c98f34390f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 7 Mar 2018 14:13:36 +0100 Subject: [PATCH] Actually clear cache values for all base urls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/Server.php | 4 ++-- lib/private/Template/JSCombiner.php | 13 +++++++++---- lib/private/Template/SCSSCacher.php | 13 +++++++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/private/Server.php b/lib/private/Server.php index ed4eb7eb39..e0bd21b035 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -965,7 +965,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getConfig(), $c->getThemingDefaults(), \OC::$SERVERROOT, - $cacheFactory->createDistributed('SCSS-' . md5($this->getURLGenerator()->getBaseUrl())) + $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-' . md5($this->getURLGenerator()->getBaseUrl())), + $this->getMemCacheFactory(), $c->getSystemConfig(), $c->getLogger() ); diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php index bc548c22fd..9368375389 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 433d5e5d0b..0f5be9643b 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) {