Signed-off-by: Morris Jobke <hey@morrisjobke.de>tags/v21.0.0beta1
$this->configLoaded = true; | $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; | |||||
} | |||||
} | } |
namespace OC\Template; | namespace OC\Template; | ||||
use OC\AppConfig; | |||||
use OC\Files\AppData\Factory; | use OC\Files\AppData\Factory; | ||||
use OC\Memcache\NullCache; | use OC\Memcache\NullCache; | ||||
use OCP\AppFramework\Utility\ITimeFactory; | use OCP\AppFramework\Utility\ITimeFactory; | ||||
/** @var IMemcache */ | /** @var IMemcache */ | ||||
private $lockingCache; | private $lockingCache; | ||||
/** @var AppConfig */ | |||||
private $appConfig; | |||||
/** | /** | ||||
* @param ILogger $logger | * @param ILogger $logger | ||||
$serverRoot, | $serverRoot, | ||||
ICacheFactory $cacheFactory, | ICacheFactory $cacheFactory, | ||||
IconsCacher $iconsCacher, | IconsCacher $iconsCacher, | ||||
ITimeFactory $timeFactory) { | |||||
ITimeFactory $timeFactory, | |||||
AppConfig $appConfig) { | |||||
$this->logger = $logger; | $this->logger = $logger; | ||||
$this->appData = $appDataFactory->get('css'); | $this->appData = $appDataFactory->get('css'); | ||||
$this->urlGenerator = $urlGenerator; | $this->urlGenerator = $urlGenerator; | ||||
$this->lockingCache = $lockingCache; | $this->lockingCache = $lockingCache; | ||||
$this->iconsCacher = $iconsCacher; | $this->iconsCacher = $iconsCacher; | ||||
$this->timeFactory = $timeFactory; | $this->timeFactory = $timeFactory; | ||||
$this->appConfig = $appConfig; | |||||
} | } | ||||
/** | /** | ||||
$retry = 0; | $retry = 0; | ||||
sleep(1); | sleep(1); | ||||
while ($retry < 10) { | while ($retry < 10) { | ||||
$this->appConfig->clearCachedConfig(); | |||||
$this->logger->debug('SCSSCacher::process check in while loop follows', ['app' => 'scss_cacher']); | $this->logger->debug('SCSSCacher::process check in while loop follows', ['app' => 'scss_cacher']); | ||||
if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $app)) { | if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $app)) { | ||||
// Inject icons vars css if any | // Inject icons vars css if any |
namespace Test\Template; | namespace Test\Template; | ||||
use OC\AppConfig; | |||||
use OC\Files\AppData\AppData; | use OC\Files\AppData\AppData; | ||||
use OC\Files\AppData\Factory; | use OC\Files\AppData\Factory; | ||||
use OC\Template\CSSResourceLocator; | use OC\Template\CSSResourceLocator; | ||||
protected $iconsCacher; | protected $iconsCacher; | ||||
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ | /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ | ||||
private $timeFactory; | private $timeFactory; | ||||
/** @var AppConfig|\PHPUnit\Framework\MockObject\MockObject */ | |||||
private $appConfig; | |||||
protected function setUp(): void { | protected function setUp(): void { | ||||
parent::setUp(); | parent::setUp(); | ||||
$this->themingDefaults = $this->createMock(ThemingDefaults::class); | $this->themingDefaults = $this->createMock(ThemingDefaults::class); | ||||
$this->iconsCacher = $this->createMock(IconsCacher::class); | $this->iconsCacher = $this->createMock(IconsCacher::class); | ||||
$this->timeFactory = $this->createMock(ITimeFactory::class); | $this->timeFactory = $this->createMock(ITimeFactory::class); | ||||
$this->appConfig = $this->createMock(AppConfig::class); | |||||
} | } | ||||
private function cssResourceLocator() { | private function cssResourceLocator() { | ||||
\OC::$SERVERROOT, | \OC::$SERVERROOT, | ||||
$this->cacheFactory, | $this->cacheFactory, | ||||
$this->iconsCacher, | $this->iconsCacher, | ||||
$this->timeFactory | |||||
$this->timeFactory, | |||||
$this->appConfig | |||||
); | ); | ||||
return new CSSResourceLocator( | return new CSSResourceLocator( | ||||
$this->logger, | $this->logger, |
namespace Test\Template; | namespace Test\Template; | ||||
use OC\AppConfig; | |||||
use OC\Files\AppData\AppData; | use OC\Files\AppData\AppData; | ||||
use OC\Files\AppData\Factory; | use OC\Files\AppData\Factory; | ||||
use OC\Template\IconsCacher; | use OC\Template\IconsCacher; | ||||
protected $iconsCacher; | protected $iconsCacher; | ||||
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ | /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ | ||||
protected $timeFactory; | protected $timeFactory; | ||||
/** @var AppConfig|\PHPUnit\Framework\MockObject\MockObject */ | |||||
protected $appConfig; | |||||
protected function setUp(): void { | protected function setUp(): void { | ||||
parent::setUp(); | parent::setUp(); | ||||
->method('getCachedCSS') | ->method('getCachedCSS') | ||||
->willReturn($iconsFile); | ->willReturn($iconsFile); | ||||
$this->appConfig = $this->createMock(AppConfig::class); | |||||
$this->scssCacher = new SCSSCacher( | $this->scssCacher = new SCSSCacher( | ||||
$this->logger, | $this->logger, | ||||
$factory, | $factory, | ||||
\OC::$SERVERROOT, | \OC::$SERVERROOT, | ||||
$this->cacheFactory, | $this->cacheFactory, | ||||
$this->iconsCacher, | $this->iconsCacher, | ||||
$this->timeFactory | |||||
$this->timeFactory, | |||||
$this->appConfig | |||||
); | ); | ||||
} | } | ||||