From 5e6d284927382ad296c6d45ec70b3d45192c02ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 3 Aug 2020 12:33:58 +0200 Subject: [PATCH] Remove old pageLogo(|Mobile) file when logo is deleted or updated --- .../install/files/lib/data/style/StyleAction.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wcfsetup/install/files/lib/data/style/StyleAction.class.php b/wcfsetup/install/files/lib/data/style/StyleAction.class.php index a8568c4f5e..a78e4e2cee 100644 --- a/wcfsetup/install/files/lib/data/style/StyleAction.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleAction.class.php @@ -172,11 +172,18 @@ class StyleAction extends AbstractDatabaseObjectAction implements IToggleAction return; } + $style->loadVariables(); foreach (['pageLogo', 'pageLogoMobile'] as $type) { if (array_key_exists($type, $this->parameters['uploads'])) { /** @var \wcf\system\file\upload\UploadFile $file */ $file = $this->parameters['uploads'][$type]; + if ($style->getVariable($type) && file_exists($style->getAssetPath().basename($style->getVariable($type)))) { + if (!$file || $style->getAssetPath().basename($style->getVariable($type)) !== $file->getLocation()) { + unlink($style->getAssetPath().basename($style->getVariable($type))); + } + } + if ($file !== null) { $fileLocation = $file->getLocation(); $extension = pathinfo($file->getFilename(), PATHINFO_EXTENSION); -- 2.20.1