Skip to content

Commit 262b435

Browse files
authored
Merge pull request #2346 from nextcloud/artonge/fix/getbyid
fix: Migrate `getById` to `getFirstNodeById`
2 parents fbb0735 + 0e390e2 commit 262b435

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/Controller/BookmarkController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ private function _returnBookmarkAsArray(Bookmark $bookmark): array {
170170
if (!isset($array['tags'])) {
171171
$array['tags'] = $this->tagMapper->findByBookmark($bookmark->getId());
172172
}
173-
if ($array['archivedFile'] !== 0) {
174-
$results = $this->rootFolder->getById($array['archivedFile']);
175-
if (count($results)) {
176-
$array['archivedFilePath'] = $results[0]->getPath();
177-
$array['archivedFileType'] = $results[0]->getMimePart();
173+
if ($array['archivedFile'] !== 0 && $array['archivedFile'] !== null) {
174+
$result = $this->rootFolder->getFirstNodeById($array['archivedFile']);
175+
if ($result !== null) {
176+
$array['archivedFilePath'] = $result->getPath();
177+
$array['archivedFileType'] = $result->getMimePart();
178178
}
179179
}
180180
return $array;

lib/Flow/CreateBookmark.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch
134134
$entity = $ruleMatcher->getEntity();
135135

136136
if ($entity instanceof File) {
137-
$node = current($this->rootFolder->getById($entity->exportContextIDs()['nodeId']));
137+
$node = $this->rootFolder->getFirstNodeById($entity->exportContextIDs()['nodeId']);
138138
if ($node !== null) {
139139
$this->handleFile($node, $user);
140140
}

0 commit comments

Comments
 (0)