Do not replace files in `custom/` during style import
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 26 Jan 2022 09:40:01 +0000 (10:40 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 26 Jan 2022 09:40:01 +0000 (10:40 +0100)
Resolves #3748

wcfsetup/install/files/lib/data/style/StyleEditor.class.php

index cc64f0102e694ecb78ba65c5e4f08ae84ff6b031..63e352c2a3d394e11e5af3ea94a4aaeca04535b0 100644 (file)
@@ -703,6 +703,15 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject
                             continue;
                         }
 
+                        // Check whether a file within the custom/ directory would be overwritten.
+                        // Skip the extraction in this case, to preserve administrator changes. A style author
+                        // can opt to use a different (versioned) file name if they *need* to update the image.
+                        if (\str_starts_with($targetFile, $style->getAssetPath() . 'custom/')) {
+                            if (\file_exists($targetFile)) {
+                                continue;
+                            }
+                        }
+
                         // duplicate pageLogo for mobile version
                         if ($duplicateLogo && $val['filename'] == $styleData['variables']['pageLogo']) {
                             $imagesTar->extract($key, $style->getAssetPath() . 'm-' . \basename($targetFile));