From 0bb62eb9456527afbcc6a66b35bbe89036f919cc Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 9 Oct 2019 19:03:27 +0200 Subject: [PATCH] Fix `MultipleSelectionFormField` save value handling As `MultipleSelectionFormField` works with arrays, it does not return an actual save value for the `data` subarray but must populate an additional entry in the parameters array itself. --- .../MultipleSelectionFormField.class.php | 39 ++++++++++++++++++- .../BoxPackageInstallationPlugin.class.php | 6 +-- .../MenuPackageInstallationPlugin.class.php | 5 ++- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/MultipleSelectionFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/MultipleSelectionFormField.class.php index 484fe87d79..bb5b5975ec 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/MultipleSelectionFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/MultipleSelectionFormField.class.php @@ -1,6 +1,8 @@ getDocument()->getDataHandler()->addProcessor( + new CustomFormDataProcessor( + 'multiple', + function(IFormDocument $document, array $parameters) { + if ($this->checkDependencies() && !empty($this->getValue())) { + $parameters[$this->getObjectProperty()] = $this->getValue(); + } + + return $parameters; + } + ) + ); + + return $this; + } + /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php index d0738ff9af..a4831f92f3 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php @@ -817,13 +817,13 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin $form ); - if (!empty($data['visibilityExceptions'])) { + if (!empty($formData['visibilityExceptions'])) { $box->appendChild($document->createElement('visibleEverywhere', (string)($data['visibleEverywhere'] ?? 0))); $visibilityExceptions = $document->createElement('visibilityExceptions'); - sort($data['visibilityExceptions']); - foreach ($data['visibilityExceptions'] as $page) { + sort($formData['visibilityExceptions']); + foreach ($formData['visibilityExceptions'] as $page) { $visibilityExceptions->appendChild($document->createElement('page', $page)); } diff --git a/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php index 9cd6cf3420..fed23cc0fb 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php @@ -555,10 +555,11 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin } } - if (!empty($formData['data']['boxVisibilityExceptions'])) { + if (!empty($formData['boxVisibilityExceptions'])) { $visibilityExceptions = $box->appendChild($document->createElement('visibilityExceptions')); - foreach ($formData['data']['boxVisibilityExceptions'] as $pageIdentifier) { + sort($formData['boxVisibilityExceptions']); + foreach ($formData['boxVisibilityExceptions'] as $pageIdentifier) { $visibilityExceptions->appendChild($document->createElement('page', $pageIdentifier)); } } -- 2.20.1