From ba33e6220cd8e07cc1723c13490e660b9789c858 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sat, 13 Jul 2024 12:22:22 +0200 Subject: fix(TaskProcessing): Use getScalarType instead of relying on magic integers Signed-off-by: Marcel Klehr --- lib/private/TaskProcessing/Manager.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/private/TaskProcessing') diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index 421bf39de07..669b0d70a80 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -773,11 +773,13 @@ class Manager implements IManager { $newInputOutput[$key] = $input[$key]; continue; } - if ($type->value < 10) { + if (EShapeType::getScalarType($type) === $type) { + // is scalar $node = $this->validateFileId((int)$input[$key]); $this->validateUserAccessToFile($input[$key], $userId); $newInputOutput[$key] = $node; } else { + // is list $newInputOutput[$key] = []; foreach ($input[$key] as $item) { $node = $this->validateFileId((int)$item); @@ -849,7 +851,7 @@ class Manager implements IManager { $newOutput[$key] = $output[$key]; continue; } - if ($type->value < 10) { + if (EShapeType::getScalarType($type) === $type) { /** @var SimpleFile $file */ $file = $folder->newFile(time() . '-' . rand(1, 100000), $output[$key]); $newOutput[$key] = $file->getId(); // polymorphic call to SimpleFile @@ -923,7 +925,7 @@ class Manager implements IManager { $newOutput[$key] = $output[$key]; continue; } - if ($type->value < 10) { + if (EShapeType::getScalarType($type) === $type) { // Is scalar file ID $newOutput[$key] = $this->validateFileId($output[$key]); } else { @@ -939,10 +941,10 @@ class Manager implements IManager { /** * @param mixed $id - * @return Node + * @return File * @throws ValidationException */ - private function validateFileId(mixed $id): Node { + private function validateFileId(mixed $id): File { $node = $this->rootFolder->getFirstNodeById($id); if ($node === null) { $node = $this->rootFolder->getFirstNodeByIdInPath($id, '/' . $this->rootFolder->getAppDataDirectoryName() . '/'); -- cgit v1.2.3