diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 59f32d0a8168f..a09048d09478e 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -43,6 +43,7 @@ use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; use OCP\Files\NotFoundException; +use OCP\Files\SimpleFS\ISimpleFile; use OCP\ICacheFactory; use OCP\IConfig; use OCP\IL10N; @@ -347,17 +348,11 @@ public function replaceImagePath($app, $image) { } $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); - try { - $customFavicon = $this->imageManager->getImage('favicon'); - } catch (NotFoundException $e) { - $customFavicon = null; - } - $route = false; - if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { + if ($image === 'favicon.ico' && ($this->imageManager->shouldReplaceIcons() || $this->getCustomFavicon() !== null)) { $route = $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]); } - if (($image === 'favicon-touch.png' || $image === 'favicon-fb.png') && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { + if (($image === 'favicon-touch.png' || $image === 'favicon-fb.png') && ($this->imageManager->shouldReplaceIcons() || $this->getCustomFavicon() !== null)) { $route = $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]); } if ($image === 'manifest.json') { @@ -381,6 +376,14 @@ public function replaceImagePath($app, $image) { return false; } + protected function getCustomFavicon(): ?ISimpleFile { + try { + return $this->imageManager->getImage('favicon'); + } catch (NotFoundException $e) { + return null; + } + } + /** * Increases the cache buster key */