diff options
author | Robin Appelman <robin@icewind.nl> | 2024-02-09 09:54:52 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-03-04 13:57:31 +0100 |
commit | e7a7b4a40184dc3da2c83e858c820625f660e48e (patch) | |
tree | 367bda0ac814376e7c771fbe4b1c40cf7f33df53 /apps/files_reminders/lib | |
parent | 4d110c1dd6ae384c00c93b4e266118004b71e498 (diff) | |
download | nextcloud-server-e7a7b4a40184dc3da2c83e858c820625f660e48e.tar.gz nextcloud-server-e7a7b4a40184dc3da2c83e858c820625f660e48e.zip |
perf: switch places that always use the first getById result to getFirstNodeById
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_reminders/lib')
-rw-r--r-- | apps/files_reminders/lib/Model/RichReminder.php | 5 | ||||
-rw-r--r-- | apps/files_reminders/lib/Notification/Notifier.php | 5 | ||||
-rw-r--r-- | apps/files_reminders/lib/Service/ReminderService.php | 4 |
3 files changed, 6 insertions, 8 deletions
diff --git a/apps/files_reminders/lib/Model/RichReminder.php b/apps/files_reminders/lib/Model/RichReminder.php index 10dc89799fe..f621a8f16d5 100644 --- a/apps/files_reminders/lib/Model/RichReminder.php +++ b/apps/files_reminders/lib/Model/RichReminder.php @@ -45,11 +45,10 @@ class RichReminder extends Reminder implements JsonSerializable { * @throws NodeNotFoundException */ public function getNode(): Node { - $nodes = $this->root->getUserFolder($this->getUserId())->getById($this->getFileId()); - if (empty($nodes)) { + $node = $this->root->getUserFolder($this->getUserId())->getFirstNodeById($this->getFileId()); + if (!$node) { throw new NodeNotFoundException(); } - $node = reset($nodes); return $node; } diff --git a/apps/files_reminders/lib/Notification/Notifier.php b/apps/files_reminders/lib/Notification/Notifier.php index f7ffa0b4437..a280c4d9336 100644 --- a/apps/files_reminders/lib/Notification/Notifier.php +++ b/apps/files_reminders/lib/Notification/Notifier.php @@ -69,11 +69,10 @@ class Notifier implements INotifier { $params = $notification->getSubjectParameters(); $fileId = $params['fileId']; - $nodes = $this->root->getUserFolder($notification->getUser())->getById($fileId); - if (empty($nodes)) { + $node = $this->root->getUserFolder($notification->getUser())->getFirstNodeById($fileId); + if (!$node) { throw new InvalidArgumentException(); } - $node = reset($nodes); $path = rtrim($node->getPath(), '/'); if (strpos($path, '/' . $notification->getUser() . '/files/') === 0) { diff --git a/apps/files_reminders/lib/Service/ReminderService.php b/apps/files_reminders/lib/Service/ReminderService.php index fabca65c45a..9d5daf0cc5e 100644 --- a/apps/files_reminders/lib/Service/ReminderService.php +++ b/apps/files_reminders/lib/Service/ReminderService.php @@ -98,8 +98,8 @@ class ReminderService { $this->reminderMapper->update($reminder); return false; } catch (DoesNotExistException $e) { - $nodes = $this->root->getUserFolder($user->getUID())->getById($fileId); - if (empty($nodes)) { + $node = $this->root->getUserFolder($user->getUID())->getFirstNodeById($fileId); + if (!$node) { throw new NodeNotFoundException(); } // Create new reminder if no reminder is found |