From 055b32777e496e8e0d0c1c38cc948e8e93f4da41 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Mon, 14 Aug 2023 17:00:47 +0200 Subject: [PATCH] Fix typo in `UploadHandler` methods see https://www.woltlab.com/community/thread/301108-uploadhandler-mit-falschem-methodennamen/ --- .../files/lib/acp/form/StyleAddForm.class.php | 4 ++-- .../lib/acp/form/UserRankAddForm.class.php | 2 +- .../file/upload/UploadHandler.class.php | 22 ++++++++++++++++--- .../builder/field/UploadFormField.class.php | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php index 1fc290d67d4..9d8b370e2e2 100644 --- a/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php @@ -400,7 +400,7 @@ public function readFormParameters() $this->uploads = []; foreach (\array_keys($this->getUploadFields()) as $field) { - $removedFiles = UploadHandler::getInstance()->getRemovedFiledByFieldId($field); + $removedFiles = UploadHandler::getInstance()->getRemovedFilesByFieldId($field); if (!empty($removedFiles)) { $this->uploads[$field] = null; } @@ -412,7 +412,7 @@ public function readFormParameters() } $this->customAssets = [ - 'removed' => UploadHandler::getInstance()->getRemovedFiledByFieldId('customAssets'), + 'removed' => UploadHandler::getInstance()->getRemovedFilesByFieldId('customAssets'), 'added' => UploadHandler::getInstance()->getFilesByFieldId('customAssets'), ]; } diff --git a/wcfsetup/install/files/lib/acp/form/UserRankAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserRankAddForm.class.php index e7b40a98342..64a005b6688 100644 --- a/wcfsetup/install/files/lib/acp/form/UserRankAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserRankAddForm.class.php @@ -181,7 +181,7 @@ public function readFormParameters() $this->hideTitle = \intval($_POST['hideTitle']); } - $this->removedRankImages = UploadHandler::getInstance()->getRemovedFiledByFieldId('rankImage'); + $this->removedRankImages = UploadHandler::getInstance()->getRemovedFilesByFieldId('rankImage'); $rankImageFiles = UploadHandler::getInstance()->getFilesByFieldId('rankImage'); $this->rankImageFile = \reset($rankImageFiles); } 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 c664575006f..fa0a77f478e 100644 --- a/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php +++ b/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php @@ -136,13 +136,21 @@ public function getFilesByFieldId($fieldId) * * @throws \InvalidArgumentException if the given fieldId is unknown */ - public function getRemovedFiledByFieldId($fieldId, $processFiles = true) + public function getRemovedFilesByFieldId($fieldId, $processFiles = true) { if (!isset($this->fields[$fieldId])) { throw new \InvalidArgumentException('UploadField with the id "' . $fieldId . '" is unknown.'); } - return $this->getRemovedFiledByInternalId($this->fields[$fieldId]->getInternalId(), $processFiles); + return $this->getRemovedFilesByInternalId($this->fields[$fieldId]->getInternalId(), $processFiles); + } + + /** + * @deprecated 6.0 This method exists only because of a spelling error in the method name. Use `getRemovedFiledByFieldId` instead. + */ + public function getRemovedFiledByFieldId($fieldId, $processFiles = true) + { + return $this->getRemovedFilesByFieldId($fieldId, $processFiles); } /** @@ -152,7 +160,7 @@ public function getRemovedFiledByFieldId($fieldId, $processFiles = true) * @param bool $processFiles * @return UploadFile[] */ - public function getRemovedFiledByInternalId($internalId, $processFiles = true) + public function getRemovedFilesByInternalId($internalId, $processFiles = true) { if (isset($this->getStorage()[$internalId])) { $files = $this->getStorage()[$internalId]['removedFiles']; @@ -175,6 +183,14 @@ public function getRemovedFiledByInternalId($internalId, $processFiles = true) return []; } + /** + * @deprecated 6.0 This method exists only because of a spelling error in the method name. Use `getRemovedFilesByInternalId` instead. + */ + public function getRemovedFiledByInternalId($internalId, $processFiles = true) + { + return $this->getRemovedFilesByInternalId($internalId, $processFiles); + } + /** * Removes a file from the upload. * 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 c66163dd5ee..785111706f1 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 @@ -185,7 +185,7 @@ public function getRemovedFiles($processFiles = false) $this->registerField(); } - return UploadHandler::getInstance()->getRemovedFiledByFieldId($this->getPrefixedId(), $processFiles); + return UploadHandler::getInstance()->getRemovedFilesByFieldId($this->getPrefixedId(), $processFiles); } /**