From 1b1f7fbe45ee0a5e276736efea5ea27c218a65ac Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Fri, 14 Aug 2020 16:29:11 +0200 Subject: [PATCH] Fix cleanup --- .../install/files/lib/acp/form/StyleAddForm.class.php | 9 +++++---- .../install/files/lib/acp/form/StyleEditForm.class.php | 2 ++ .../files/lib/acp/form/StyleGlobalValuesForm.class.php | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index acd1900c2d..9368b72da9 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -477,6 +477,8 @@ class StyleAddForm extends AbstractForm { $result = StyleCompiler::getInstance()->testStyle($this->styleTestFileDir, $this->apiVersion, false, $variables); if ($result !== null) { + rmdir($this->styleTestFileDir); + throw new UserInputException('individualScss', [ 'message' => $result->getMessage(), ]); @@ -797,11 +799,10 @@ class StyleAddForm extends AbstractForm { 'styleDescription' => 'wcf.style.styleDescription'.$style->styleID ]); - // save compiled style + // Do not save the compiled style, because the image path was unknown during the style generation. if ($this->styleTestFileDir && file_exists($this->styleTestFileDir . '/style.css') && file_exists($this->styleTestFileDir . '/style-rtl.css')) { - $styleFilename = StyleCompiler::getFilenameForStyle($style); - rename($this->styleTestFileDir . '/style.css', $styleFilename . '.css'); - rename($this->styleTestFileDir . '/style-rtl.css', $styleFilename . '-rtl.css'); + unlink($this->styleTestFileDir . '/style.css'); + unlink($this->styleTestFileDir . '/style-rtl.css'); rmdir($this->styleTestFileDir); } diff --git a/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php index ece7586aff..e2ddd55d8d 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php @@ -85,6 +85,8 @@ class StyleEditForm extends StyleAddForm { $result = StyleCompiler::getInstance()->testStyle($this->styleTestFileDir, $this->apiVersion, false, $variables); if ($result !== null) { + rmdir($this->styleTestFileDir); + throw new UserInputException('individualScss', [ 'message' => $result->getMessage(), ]); diff --git a/wcfsetup/install/files/lib/acp/form/StyleGlobalValuesForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleGlobalValuesForm.class.php index fbf945e453..8b644a477a 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleGlobalValuesForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleGlobalValuesForm.class.php @@ -85,6 +85,8 @@ class StyleGlobalValuesForm extends AbstractForm { $errorMessage = StyleCompiler::getInstance()->testStyle($this->styleTestFileDir, $defaultStyle->apiVersion, $defaultStyle->imagePath, $defaultStyle->getVariables(), $tmpFile); if ($errorMessage !== null) { + rmdir($this->styleTestFileDir); + throw new UserInputException('styles', [ 'message' => $errorMessage->getMessage(), ]); -- 2.20.1