Do not error out if assets are missing in StyleEditForm
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 9 Sep 2020 14:27:53 +0000 (16:27 +0200)
committerTim Düsterhus <timwolla@googlemail.com>
Wed, 9 Sep 2020 14:49:48 +0000 (16:49 +0200)
Resolves #3560

wcfsetup/install/files/lib/acp/form/StyleEditForm.class.php

index 9f1f8208ed19cdff7ecf13cf8f3384472484abd1..4bf634d3cfb2c38aef4da193246178b42f7c6acb 100644 (file)
@@ -138,13 +138,13 @@ class StyleEditForm extends StyleAddForm {
                        $this->variables['overrideScssCustom'] = $tmp['custom'];
                }
                
-               if ($this->variables['pageLogo']) {
+               if ($this->variables['pageLogo'] && file_exists($this->style->getAssetPath().$this->variables['pageLogo'])) {
                        $file = new UploadFile($this->style->getAssetPath().$this->variables['pageLogo'], basename($this->variables['pageLogo']), true, true, true);
                        UploadHandler::getInstance()->registerFilesByField('pageLogo', [
                                $file,
                        ]);
                }
-               if ($this->variables['pageLogoMobile']) {
+               if ($this->variables['pageLogoMobile'] && file_exists($this->style->getAssetPath().$this->variables['pageLogoMobile'])) {
                        $file = new UploadFile($this->style->getAssetPath().$this->variables['pageLogoMobile'], basename($this->variables['pageLogoMobile']), true, true, true);
                        UploadHandler::getInstance()->registerFilesByField('pageLogoMobile', [
                                $file,
@@ -185,19 +185,19 @@ class StyleEditForm extends StyleAddForm {
                        $this->styleName = $this->style->styleName;
                        $this->styleVersion = $this->style->styleVersion;
                        $this->templateGroupID = $this->style->templateGroupID;
-                       if ($this->style->image) {
+                       if ($this->style->image && file_exists(WCF_DIR.'images/'.$this->style->image)) {
                                $file = new UploadFile(WCF_DIR.'images/'.$this->style->image, $this->style->image, true, true, false);
                                UploadHandler::getInstance()->registerFilesByField('image', [
                                        $file,
                                ]);
                        }
-                       if ($this->style->image2x) {
+                       if ($this->style->image2x && file_exists(WCF_DIR.'images/'.$this->style->image2x)) {
                                $file = new UploadFile(WCF_DIR.'images/'.$this->style->image2x, $this->style->image2x, true, true, false);
                                UploadHandler::getInstance()->registerFilesByField('image2x', [
                                        $file,
                                ]);
                        }
-                       if ($this->style->coverPhotoExtension) {
+                       if ($this->style->coverPhotoExtension && file_exists($this->style->getCoverPhotoLocation())) {
                                $file = new UploadFile($this->style->getCoverPhotoLocation(), $this->style->getCoverPhoto(), true, true, false);
                                UploadHandler::getInstance()->registerFilesByField('coverPhoto', [
                                        $file,