From: Tim Düsterhus Date: Fri, 18 Dec 2020 12:44:57 +0000 (+0100) Subject: Fix style previews pointing to the style's asset folder X-Git-Tag: 5.3.2~35^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1135ea01ad19bdb7f46c3154c0bad8324bc3dac9;p=GitHub%2FWoltLab%2FWCF.git Fix style previews pointing to the style's asset folder update_com.woltlab.wcf_5.3.1_style.php created this situation when the style did not have a preview image, due to a missing check for a non-empty `image` / `image2x` property. --- diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index 4832279135..235d02156d 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -104,22 +104,9 @@ update_5.3.sql - - + - - acptemplates_update.tar - files_update.tar - templates_update.tar - - - - - - acp/update_com.woltlab.wcf_5.3.1_style.php - acp/update_com.woltlab.wcf_5.3_orphanedComments.php - diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3.1_style.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3.1_style.php deleted file mode 100644 index 535706b4b9..0000000000 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3.1_style.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @package WoltLabSuite\Core - */ - -$styleList = new StyleList(); -$styleList->readObjects(); - -foreach ($styleList as $style) { - $styleEditor = new StyleEditor($style); - - // Fix the name of the favicon template. - foreach ([ - 'gif', - 'jpeg', - 'jpg', - 'png', - ] as $extension) { - if (file_exists($style->getAssetPath() . 'favicon.template.' . $extension)) { - rename( - $style->getAssetPath() . 'favicon.template.' . $extension, - $style->getAssetPath() . 'favicon-template.' . $extension - ); - } - } - - // Fix the style preview. - if ( - $style->image === basename($style->image) && - file_exists($style->getAssetPath() . $style->image) - ) { - $styleEditor->update([ - 'image' => FileUtil::getRelativePath(WCF_DIR.'images/', $style->getAssetPath()) . $style->image, - ]); - } - - if ( - $style->image2x === basename($style->image2x) && - file_exists($style->getAssetPath() . $style->image2x) - ) { - $styleEditor->update([ - 'image2x' => FileUtil::getRelativePath(WCF_DIR.'images/', $style->getAssetPath()) . $style->image2x, - ]); - } -} diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3.2_style.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3.2_style.php new file mode 100644 index 0000000000..7fa8fa9224 --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.3.2_style.php @@ -0,0 +1,38 @@ + + * @package WoltLabSuite\Core + */ + +$styleList = new StyleList(); +$styleList->readObjects(); + +foreach ($styleList as $style) { + $styleEditor = new StyleEditor($style); + + // Fix the style preview. + if ( + $style->image === FileUtil::getRelativePath(WCF_DIR.'images/', $style->getAssetPath()) || + !is_file($style->image) + ) { + $styleEditor->update([ + 'image' => '', + ]); + } + + if ( + $style->image2x === FileUtil::getRelativePath(WCF_DIR.'images/', $style->getAssetPath()) || + !is_file($style->image2x) + ) { + $styleEditor->update([ + 'image2x' => '', + ]); + } +}