Skip to content

Commit e8090c8

Browse files
committed
fix: Migrate getById to getFirstNodeById
Signed-off-by: Louis Chmn <louis@chmn.me>
1 parent 34c2125 commit e8090c8

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

apps/workflowengine/lib/Entity/File.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,9 @@ protected function getNode(): Node {
136136
if (!$this->event instanceof MapperEvent || $this->event->getObjectType() !== 'files') {
137137
throw new NotFoundException();
138138
}
139-
$nodes = $this->root->getById((int)$this->event->getObjectId());
140-
if (is_array($nodes) && isset($nodes[0])) {
141-
$this->node = $nodes[0];
142-
return $this->node;
143-
}
144-
break;
139+
$node = $this->root->getFirstNodeById((int)$this->event->getObjectId());
140+
$this->node = $node;
141+
return $this->node;
145142
}
146143
throw new NotFoundException();
147144
}
@@ -228,11 +225,11 @@ public function importContextIDs(array $contextIDs): void {
228225
$this->eventName = $contextIDs['eventName'];
229226
if ($contextIDs['nodeOwnerId'] !== null) {
230227
$userFolder = $this->root->getUserFolder($contextIDs['nodeOwnerId']);
231-
$nodes = $userFolder->getById($contextIDs['nodeId']);
228+
$node = $userFolder->getFirstNodeById($contextIDs['nodeId']);
232229
} else {
233-
$nodes = $this->root->getById($contextIDs['nodeId']);
230+
$node = $this->root->getFirstNodeById($contextIDs['nodeId']);
234231
}
235-
$this->node = $nodes[0] ?? null;
232+
$this->node = $node;
236233
if ($contextIDs['actingUserId']) {
237234
$this->actingUser = $this->userManager->get($contextIDs['actingUserId']);
238235
}

lib/private/Files/Node/Root.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public function getFirstNodeByIdInPath(int $id, string $path): ?INode {
388388
}
389389
}
390390
}
391-
$node = current($this->getByIdInPath($id, $path));
391+
$node = $this->getFirstNodeByIdInPath($id, $path);
392392
if (!$node) {
393393
return null;
394394
}

0 commit comments

Comments
 (0)