]> source.dussan.org Git - nextcloud-server.git/commitdiff
Clear cached app config while waiting for the SCSSCache to finish processing the... 23513/head
authorMorris Jobke <hey@morrisjobke.de>
Thu, 15 Oct 2020 13:59:21 +0000 (15:59 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Fri, 16 Oct 2020 13:46:59 +0000 (15:46 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
lib/private/AppConfig.php
lib/private/Template/SCSSCacher.php
tests/lib/Template/CSSResourceLocatorTest.php
tests/lib/Template/SCSSCacherTest.php

index b35bc4070dd75a2e069c16268eb5fdca318dedb2..d3b644498796b8b24a8ae7a5e39f5e60c2e18594 100644 (file)
@@ -344,4 +344,14 @@ class AppConfig implements IAppConfig {
 
                $this->configLoaded = true;
        }
+
+       /**
+        * Clear all the cached app config values
+        *
+        * WARNING: do not use this - this is only for usage with the SCSSCacher to
+        * clear the memory cache of the app config
+        */
+       public function clearCachedConfig() {
+               $this->configLoaded = false;
+       }
 }
index 597d4323d3c2fdacbe3fd7e36d26cd56e8e23f08..f19674776b81a675437b816b4d02a025337170bd 100644 (file)
@@ -30,6 +30,7 @@
 
 namespace OC\Template;
 
+use OC\AppConfig;
 use OC\Files\AppData\Factory;
 use OC\Memcache\NullCache;
 use OCP\AppFramework\Utility\ITimeFactory;
@@ -89,6 +90,8 @@ class SCSSCacher {
 
        /** @var IMemcache */
        private $lockingCache;
+       /** @var AppConfig */
+       private $appConfig;
 
        /**
         * @param ILogger $logger
@@ -109,7 +112,8 @@ class SCSSCacher {
                                                                $serverRoot,
                                                                ICacheFactory $cacheFactory,
                                                                IconsCacher $iconsCacher,
-                                                               ITimeFactory $timeFactory) {
+                                                               ITimeFactory $timeFactory,
+                                                               AppConfig $appConfig) {
                $this->logger       = $logger;
                $this->appData      = $appDataFactory->get('css');
                $this->urlGenerator = $urlGenerator;
@@ -126,6 +130,7 @@ class SCSSCacher {
                $this->lockingCache = $lockingCache;
                $this->iconsCacher = $iconsCacher;
                $this->timeFactory = $timeFactory;
+               $this->appConfig = $appConfig;
        }
 
        /**
@@ -166,6 +171,7 @@ class SCSSCacher {
                        $retry = 0;
                        sleep(1);
                        while ($retry < 10) {
+                               $this->appConfig->clearCachedConfig();
                                $this->logger->debug('SCSSCacher::process check in while loop follows', ['app' => 'scss_cacher']);
                                if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $app)) {
                                        // Inject icons vars css if any
index 42fa06a474de92c80e86603ac87d4eb4f23d2027..d50ad708d0426f9b15175a8c8d9a3ce54758ae5a 100644 (file)
@@ -23,6 +23,7 @@
 
 namespace Test\Template;
 
+use OC\AppConfig;
 use OC\Files\AppData\AppData;
 use OC\Files\AppData\Factory;
 use OC\Template\CSSResourceLocator;
@@ -53,6 +54,8 @@ class CSSResourceLocatorTest extends \Test\TestCase {
        protected $iconsCacher;
        /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
        private $timeFactory;
+       /** @var AppConfig|\PHPUnit\Framework\MockObject\MockObject */
+       private $appConfig;
 
        protected function setUp(): void {
                parent::setUp();
@@ -65,6 +68,7 @@ class CSSResourceLocatorTest extends \Test\TestCase {
                $this->themingDefaults = $this->createMock(ThemingDefaults::class);
                $this->iconsCacher = $this->createMock(IconsCacher::class);
                $this->timeFactory = $this->createMock(ITimeFactory::class);
+               $this->appConfig = $this->createMock(AppConfig::class);
        }
 
        private function cssResourceLocator() {
@@ -80,7 +84,8 @@ class CSSResourceLocatorTest extends \Test\TestCase {
                        \OC::$SERVERROOT,
                        $this->cacheFactory,
                        $this->iconsCacher,
-                       $this->timeFactory
+                       $this->timeFactory,
+                       $this->appConfig
                );
                return new CSSResourceLocator(
                        $this->logger,
index 1a77f789afe19d930cef1a9ac151adeaaff743df..77a9bdde764ea96b84bb03f2a2e00f0e6d4eecd2 100644 (file)
@@ -23,6 +23,7 @@
 
 namespace Test\Template;
 
+use OC\AppConfig;
 use OC\Files\AppData\AppData;
 use OC\Files\AppData\Factory;
 use OC\Template\IconsCacher;
@@ -60,6 +61,8 @@ class SCSSCacherTest extends \Test\TestCase {
        protected $iconsCacher;
        /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
        protected $timeFactory;
+       /** @var AppConfig|\PHPUnit\Framework\MockObject\MockObject */
+       protected $appConfig;
 
        protected function setUp(): void {
                parent::setUp();
@@ -92,6 +95,8 @@ class SCSSCacherTest extends \Test\TestCase {
                        ->method('getCachedCSS')
                        ->willReturn($iconsFile);
 
+               $this->appConfig = $this->createMock(AppConfig::class);
+
                $this->scssCacher = new SCSSCacher(
                        $this->logger,
                        $factory,
@@ -101,7 +106,8 @@ class SCSSCacherTest extends \Test\TestCase {
                        \OC::$SERVERROOT,
                        $this->cacheFactory,
                        $this->iconsCacher,
-                       $this->timeFactory
+                       $this->timeFactory,
+                       $this->appConfig
                );
        }