From ba45d5966c77678a2f130c7ad8598238f914f978 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Wed, 31 Jul 2024 07:41:48 +0200 Subject: [PATCH] Add additional checks as to whether the `$bigPreview` is active or can be activated --- .../field/FileProcessorFormField.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php index a41b418e81..3038e92020 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php @@ -96,6 +96,12 @@ final class FileProcessorFormField extends AbstractFormField */ public function singleFileUpload(bool $singleFileUpload = true): self { + if (!$singleFileUpload && $this->bigPreview) { + throw new \InvalidArgumentException( + "Single file upload can't be disabled if the big preview is enabled for the field '{$this->getId()}'." + ); + } + $this->singleFileUpload = $singleFileUpload; return $this; @@ -229,7 +235,7 @@ final class FileProcessorFormField extends AbstractFormField public function bigPreview(bool $bigPreview = true): self { if ( - $this->bigPreview + $bigPreview && \array_diff( $this->getFileProcessor()->getAllowedFileExtensions($this->context), ImageUtil::IMAGE_EXTENSIONS @@ -239,6 +245,13 @@ final class FileProcessorFormField extends AbstractFormField "The big preview is only supported for images for the field '{$this->getId()}'." ); } + + if ($bigPreview && !$this->singleFileUpload) { + throw new \InvalidArgumentException( + "The big preview is only supported for single file uploads for the field '{$this->getId()}'." + ); + } + $this->bigPreview = $bigPreview; return $this; -- 2.20.1