Fix cleanup
authorjoshuaruesweg <ruesweg@woltlab.com>
Fri, 14 Aug 2020 14:29:11 +0000 (16:29 +0200)
committerjoshuaruesweg <ruesweg@woltlab.com>
Fri, 14 Aug 2020 14:29:11 +0000 (16:29 +0200)
wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php
wcfsetup/install/files/lib/acp/form/StyleGlobalValuesForm.class.php

index acd1900c2d35b116dbd7a2b720ff16205fef8c9c..9368b72da9a2717b17cbf8a40c665e6b9f7119c7 100644 (file)
@@ -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);
                }
index ece7586affa62980b8a882308c62d96388058bd2..e2ddd55d8d1b0d1a93d8d91407d14350ce5ed8b5 100644 (file)
@@ -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(),
                        ]);
index fbf945e453e5d3a0391722048f8029497705943f..8b644a477a397b8241f0de9cee366e3e5f33ff2b 100644 (file)
@@ -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(),
                                        ]);