Merge pull request #29221 from nextcloud/backport/29214/stable22

[stable22] Don't setup the filesystem to check for a favicon we don't use anyway
This commit is contained in:
blizzz 2021-10-14 12:51:32 +02:00 committed by GitHub
commit cc28d5c16c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,6 +43,7 @@ namespace OCA\Theming;
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;
@ -354,17 +355,11 @@ class ThemingDefaults extends \OC_Defaults {
}
$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') {
@ -388,6 +383,14 @@ class ThemingDefaults extends \OC_Defaults {
return false;
}
protected function getCustomFavicon(): ?ISimpleFile {
try {
return $this->imageManager->getImage('favicon');
} catch (NotFoundException $e) {
return null;
}
}
/**
* Increases the cache buster key
*/