From: Joshua Rüsweg Date: Fri, 5 Apr 2019 18:26:13 +0000 (+0200) Subject: Add parameter to add the request data to the UploadHandler X-Git-Tag: 5.2.0_Alpha_1~169 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=914a8fbad2b33e033363834fdac80fa14b7265e1;p=GitHub%2FWoltLab%2FWCF.git Add parameter to add the request data to the UploadHandler See #2509 See #2825 --- diff --git a/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php b/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php index 1c32d969cc..80465ff79b 100644 --- a/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php +++ b/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php @@ -39,17 +39,22 @@ class UploadHandler extends SingletonFactory { * Registers a UploadField. * * @param UploadField $field + * @param mixed $requestData * * @throws \InvalidArgumentException if a field with the given fieldId is already registered */ - public function registerUploadField(UploadField $field) { + public function registerUploadField(UploadField $field, array $requestData = null) { if (isset($this->fields[$field->getFieldId()])) { throw new \InvalidArgumentException('UploadField with the id "'. $field->getFieldId() .'" is already registered.'); } + if ($requestData === null) { + $requestData = $_POST; + } + // read internal identifier - if (!empty($_POST) && isset($_POST[$field->getFieldId()]) && $this->isValidInternalId($_POST[$field->getFieldId()])) { - $field->setInternalId($_POST[$field->getFieldId()]); + if (!empty($requestData) && isset($requestData[$field->getFieldId()]) && $this->isValidInternalId($requestData[$field->getFieldId()])) { + $field->setInternalId($requestData[$field->getFieldId()]); $this->fields[$field->getFieldId()] = $field; } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php index c078d8aa4c..59f4ee2c0a 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php @@ -52,7 +52,7 @@ class UploadFormField extends AbstractFormField { */ private function registerField() { if (!UploadHandler::getInstance()->isRegisteredFieldId($this->getPrefixedId())) { - UploadHandler::getInstance()->registerUploadField($this->buildUploadField()); + UploadHandler::getInstance()->registerUploadField($this->buildUploadField(), $this->getDocument()->getRequestData()); } }