From b8b21d884190d99aee36f83ca695f542404978c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Sun, 20 Jan 2019 18:16:43 +0100 Subject: [PATCH] Fix typo in method names See #2825 --- .../lib/action/AJAXFileUploadAction.class.php | 6 +-- .../file/upload/UploadHandler.class.php | 47 ++++++++++--------- .../builder/field/UploadFormField.class.php | 4 +- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/wcfsetup/install/files/lib/action/AJAXFileUploadAction.class.php b/wcfsetup/install/files/lib/action/AJAXFileUploadAction.class.php index 01fe196857..13e472ec52 100644 --- a/wcfsetup/install/files/lib/action/AJAXFileUploadAction.class.php +++ b/wcfsetup/install/files/lib/action/AJAXFileUploadAction.class.php @@ -66,7 +66,7 @@ class AJAXFileUploadAction extends AbstractSecureAction { throw new UserInputException('files', 'failed'); } - if (UploadHandler::getInstance()->getFieldForInternalId($this->internalId)->getMaxFiles() !== null && UploadHandler::getInstance()->getFieldForInternalId($this->internalId)->getMaxFiles() < UploadHandler::getInstance()->getFilesCountForInternalId($this->internalId) + count($_FILES['__files']['tmp_name'])) { + if (UploadHandler::getInstance()->getFieldByInternalId($this->internalId)->getMaxFiles() !== null && UploadHandler::getInstance()->getFieldByInternalId($this->internalId)->getMaxFiles() < UploadHandler::getInstance()->getFilesCountByInternalId($this->internalId) + count($_FILES['__files']['tmp_name'])) { throw new UserInputException('files', 'reachedRemainingLimit'); } } @@ -84,7 +84,7 @@ class AJAXFileUploadAction extends AbstractSecureAction { $i = 0; - $field = UploadHandler::getInstance()->getFieldForInternalId($this->internalId); + $field = UploadHandler::getInstance()->getFieldByInternalId($this->internalId); foreach ($_FILES['__files']['tmp_name'] as $id => $tmpName) { if ($field->isImageOnly()) { @@ -109,7 +109,7 @@ class AJAXFileUploadAction extends AbstractSecureAction { $uploadFile = new UploadFile($tmpFile, $_FILES['__files']['name'][$id]); - UploadHandler::getInstance()->addFileForInternalId($this->internalId, $uploadFile); + UploadHandler::getInstance()->addFileByInternalId($this->internalId, $uploadFile); $this->uploadedFiles[$i++] = $uploadFile; } 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 d9a7dc4736..53bacb637a 100644 --- a/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php +++ b/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php @@ -63,12 +63,12 @@ class UploadHandler extends SingletonFactory { * * @throws \InvalidArgumentException if the given fieldId is unknown */ - public function getFilesForFieldId($fieldId) { + public function getFilesByFieldId($fieldId) { if (!isset($this->fields[$fieldId])) { throw new \InvalidArgumentException('UploadField with the id "'. $fieldId .'" is unknown.'); } - return $this->getFilesForInternalId($this->fields[$fieldId]->getInternalId()); + return $this->getFilesByInternalId($this->fields[$fieldId]->getInternalId()); } /** @@ -80,12 +80,12 @@ class UploadHandler extends SingletonFactory { * * @throws \InvalidArgumentException if the given fieldId is unknown */ - public function getRemovedFiledForFieldId($fieldId, $processFiles = true) { + public function getRemovedFiledByFieldId($fieldId, $processFiles = true) { if (!isset($this->fields[$fieldId])) { throw new \InvalidArgumentException('UploadField with the id "'. $fieldId .'" is unknown.'); } - return $this->getRemovedFiledForInternalId($this->fields[$fieldId]->getInternalId(), $processFiles); + return $this->getRemovedFiledByInternalId($this->fields[$fieldId]->getInternalId(), $processFiles); } /** @@ -95,7 +95,7 @@ class UploadHandler extends SingletonFactory { * @param boolean $processFiles * @return UploadFile[] */ - public function getRemovedFiledForInternalId($internalId, $processFiles = true) { + public function getRemovedFiledByInternalId($internalId, $processFiles = true) { if (isset($this->getStorage()[$internalId])) { $files = $this->getStorage()[$internalId]['removedFiles']; $removedFiles = []; @@ -107,7 +107,7 @@ class UploadHandler extends SingletonFactory { } } - if ($processFiles) $this->processRemovedFiles($this->getFieldForInternalId($internalId)); + if ($processFiles) $this->processRemovedFiles($this->getFieldByInternalId($internalId)); return $removedFiles; } @@ -128,7 +128,7 @@ class UploadHandler extends SingletonFactory { throw new \InvalidArgumentException('InternalId "'. $internalId .'" is unknown.'); } - $file = $this->getFileForUniqueFileId($internalId, $uniqueFileId); + $file = $this->getFileByUniqueFileId($internalId, $uniqueFileId); if ($file === null) { return; @@ -170,7 +170,7 @@ class UploadHandler extends SingletonFactory { return WCF::getTPL()->fetch('uploadFieldComponent', 'wcf', [ 'uploadField' => $this->fields[$fieldId], 'uploadFieldId' => $fieldId, - 'uploadFieldFiles' => $this->getFilesForFieldId($fieldId) + 'uploadFieldFiles' => $this->getFilesByFieldId($fieldId) ]); } @@ -192,23 +192,24 @@ class UploadHandler extends SingletonFactory { * @return boolean */ public function isValidUniqueFileId($internalId, $uniqueFileId) { - return $this->getFileForUniqueFileId($internalId, $uniqueFileId) !== null; + return $this->getFileByUniqueFileId($internalId, $uniqueFileId) !== null; } /** - * + * Return all files by file id. + * * @param string $internalId * @param string $uniqueFileId * @return UploadFile|null * * @throws \InvalidArgumentException if the given internalId is unknown */ - public function getFileForUniqueFileId($internalId, $uniqueFileId) { + public function getFileByUniqueFileId($internalId, $uniqueFileId) { if (!$this->isValidInternalId($internalId)) { throw new \InvalidArgumentException('InternalId "'. $internalId .'" is unknown.'); } - foreach ($this->getFilesForInternalId($internalId) as $file) { + foreach ($this->getFilesByInternalId($internalId) as $file) { if (hash_equals($file->getUniqueFileId(), $uniqueFileId)) { return $file; } @@ -223,8 +224,8 @@ class UploadHandler extends SingletonFactory { * @param string $internalId * @param UploadFile $file */ - public function addFileForInternalId($internalId, UploadFile $file) { - $this->registerFilesForInternalId($internalId, array_merge($this->getFilesForInternalId($internalId), [$file])); + public function addFileByInternalId($internalId, UploadFile $file) { + $this->registerFilesByInternalId($internalId, array_merge($this->getFilesByInternalId($internalId), [$file])); } /** @@ -238,7 +239,7 @@ class UploadHandler extends SingletonFactory { * * @throws \InvalidArgumentException if the given internalId is unknown */ - public function registerFilesForInternalId($internalId, array $files) { + public function registerFilesByInternalId($internalId, array $files) { if (!$this->isValidInternalId($internalId)) { throw new \InvalidArgumentException('InternalId "'. $internalId .'" is unknown.'); } @@ -261,8 +262,8 @@ class UploadHandler extends SingletonFactory { * @param string $fieldId * @param UploadFile $file */ - public function addFileForField($fieldId, UploadFile $file) { - $this->registerFilesForField($fieldId, array_merge($this->getFilesForFieldId($fieldId), [$file])); + public function addFileByField($fieldId, UploadFile $file) { + $this->registerFilesByField($fieldId, array_merge($this->getFilesByFieldId($fieldId), [$file])); } /** @@ -276,12 +277,12 @@ class UploadHandler extends SingletonFactory { * * @throws \InvalidArgumentException if the given fieldId is unknown */ - public function registerFilesForField($fieldId, array $files) { + public function registerFilesByField($fieldId, array $files) { if (!isset($this->fields[$fieldId])) { throw new \InvalidArgumentException('UploadField with the id "'. $fieldId .'" is unknown.'); } - $this->registerFilesForInternalId($this->fields[$fieldId]->getInternalId(), $files); + $this->registerFilesByInternalId($this->fields[$fieldId]->getInternalId(), $files); } /** @@ -292,7 +293,7 @@ class UploadHandler extends SingletonFactory { * * @throws \InvalidArgumentException if the given internalId is unknown */ - public function getFieldForInternalId($internalId) { + public function getFieldByInternalId($internalId) { if (!$this->isValidInternalId($internalId)) { throw new \InvalidArgumentException('InternalId "'. $internalId .'" is unknown.'); } @@ -306,8 +307,8 @@ class UploadHandler extends SingletonFactory { * @param string $internalId * @return int */ - public function getFilesCountForInternalId($internalId) { - return count($this->getFilesForInternalId($internalId)); + public function getFilesCountByInternalId($internalId) { + return count($this->getFilesByInternalId($internalId)); } /** @@ -326,7 +327,7 @@ class UploadHandler extends SingletonFactory { * @param string $internalId * @return UploadFile[] */ - private function getFilesForInternalId($internalId) { + private function getFilesByInternalId($internalId) { if (isset($this->getStorage()[$internalId])) { $files = $this->getStorage()[$internalId]['files']; 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 e4e2c4fa63..d145ca3f89 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 @@ -67,7 +67,7 @@ class UploadFormField extends AbstractFormField { * @return UploadFile[] */ public function getValue() { - return UploadHandler::getInstance()->getFilesForFieldId($this->getId()); + return UploadHandler::getInstance()->getFilesByFieldId($this->getId()); } /** @@ -137,7 +137,7 @@ class UploadFormField extends AbstractFormField { $this->registerField(); - UploadHandler::getInstance()->registerFilesForField($this->getId(), $value); + UploadHandler::getInstance()->registerFilesByField($this->getId(), $value); } /** -- 2.20.1