aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/TaskProcessing/Manager.php
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2024-07-13 12:22:22 +0200
committerMarcel Klehr <mklehr@gmx.net>2024-07-17 13:55:55 +0200
commitba33e6220cd8e07cc1723c13490e660b9789c858 (patch)
treede1182bf07ce30d363dd792e2f3d1b8c907f6273 /lib/private/TaskProcessing/Manager.php
parent61ebfad72413c9202514366c5f71dca6cc08a8b4 (diff)
downloadnextcloud-server-ba33e6220cd8e07cc1723c13490e660b9789c858.tar.gz
nextcloud-server-ba33e6220cd8e07cc1723c13490e660b9789c858.zip
fix(TaskProcessing): Use getScalarType instead of relying on magic integers
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/private/TaskProcessing/Manager.php')
-rw-r--r--lib/private/TaskProcessing/Manager.php12
1 files changed, 7 insertions, 5 deletions
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() . '/');