]> source.dussan.org Git - nextcloud-server.git/commitdiff
Shortcut to avoid file system setup when generating the logo URL 24001/head
authorMorris Jobke <hey@morrisjobke.de>
Wed, 4 Nov 2020 08:59:32 +0000 (09:59 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 9 Nov 2020 13:13:31 +0000 (13:13 +0000)
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>
apps/theming/lib/ThemingDefaults.php
apps/theming/tests/ThemingDefaultsTest.php

index 3fdbc1a61ae2fde8b0b2152d34073460fb9e069a..e710bee3f63b546881edc95f58d682f6b85ce5e3 100644 (file)
@@ -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');
index fecde37262285a8623a41d98b2aa91b804cfc237..3220870f8ea3f0e28db42810ce9fdc2dc69726b3 100644 (file)
@@ -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')