diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-11-04 09:59:32 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-11-09 13:13:31 +0000 |
commit | cc777911c204118924602e4edc3b7b11fe176983 (patch) | |
tree | 53b33ef94878739a83b41d6213edadb21b7884c1 /apps | |
parent | 3459db047227d55acef9081e8a0fd1d5005a9ad8 (diff) | |
download | nextcloud-server-cc777911c204118924602e4edc3b7b11fe176983.tar.gz nextcloud-server-cc777911c204118924602e4edc3b7b11fe176983.zip |
Shortcut to avoid file system setup when generating the logo URL
If an SVG is requested and the app config value for logoMime is set then the logo is there. Otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which needs to be called then).
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 19 | ||||
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 6 |
2 files changed, 14 insertions, 11 deletions
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 3fdbc1a61ae..e710bee3f63 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -225,11 +225,20 @@ class ThemingDefaults extends \OC_Defaults { public function getLogo($useSvg = true): string { $logo = $this->config->getAppValue('theming', 'logoMime', false); - $logoExists = true; - try { - $this->imageManager->getImage('logo', $useSvg); - } catch (\Exception $e) { - $logoExists = false; + // short cut to avoid setting up the filesystem just to check if the logo is there + // + // explanation: if an SVG is requested and the app config value for logoMime is set then the logo is there. + // otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which + // needs to be called then) + if ($useSvg === true && $logo !== false) { + $logoExists = true; + } else { + try { + $this->imageManager->getImage('logo', $useSvg); + $logoExists = true; + } catch (\Exception $e) { + $logoExists = false; + } } $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index fecde372622..3220870f8ea 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -40,7 +40,6 @@ use OCA\Theming\Util; use OCP\App\IAppManager; use OCP\Files\IAppData; use OCP\Files\NotFoundException; -use OCP\Files\SimpleFS\ISimpleFile; use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; @@ -617,11 +616,6 @@ class ThemingDefaultsTest extends TestCase { } public function testGetLogoCustom() { - $file = $this->createMock(ISimpleFile::class); - $this->imageManager->expects($this->once()) - ->method('getImage') - ->with('logo') - ->willReturn($file); $this->config ->expects($this->at(0)) ->method('getAppValue') |