From 20519434879dd0ee9278d0871d92e9c11295adfd Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 7 Dec 2018 01:27:49 +0100 Subject: [PATCH] more caching for theming Signed-off-by: Robin Appelman --- lib/private/Template/IconsCacher.php | 15 +++++++++++++-- tests/lib/Template/IconsCacherTest.php | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php index aab3295405..0d838c4d06 100644 --- a/lib/private/Template/IconsCacher.php +++ b/lib/private/Template/IconsCacher.php @@ -58,6 +58,9 @@ class IconsCacher { private $iconList = 'icons-list.template'; + private $cachedCss; + private $cachedList; + /** * @param ILogger $logger * @param Factory $appDataFactory @@ -137,6 +140,8 @@ class IconsCacher { $cachedVarsCssFile->putContent($data); $list = ":root {\n$list\n}"; $cachedFile->putContent($list); + $this->cachedList = null; + $this->cachedCss = null; } return preg_replace($this->iconVarRE, '', $css); @@ -204,7 +209,10 @@ class IconsCacher { */ public function getCachedCSS() { try { - return $this->folder->getFile($this->fileName); + if (!$this->cachedCss) { + $this->cachedCss = $this->folder->getFile($this->fileName); + } + return $this->cachedCss; } catch (NotFoundException $e) { return false; } @@ -216,7 +224,10 @@ class IconsCacher { */ public function getCachedList() { try { - return $this->folder->getFile($this->iconList); + if (!$this->cachedList) { + $this->cachedList = $this->folder->getFile($this->iconList); + } + return $this->cachedList; } catch (NotFoundException $e) { return false; } diff --git a/tests/lib/Template/IconsCacherTest.php b/tests/lib/Template/IconsCacherTest.php index cc6224f322..3762435644 100644 --- a/tests/lib/Template/IconsCacherTest.php +++ b/tests/lib/Template/IconsCacherTest.php @@ -144,7 +144,7 @@ class IconsCacherTest extends \Test\TestCase { "; $iconsFile = $this->createMock(ISimpleFile::class); - $this->folder->expects($this->exactly(6)) + $this->folder->expects($this->exactly(4)) ->method('getFile') ->willReturn($iconsFile);