diff --git a/components/Conversation/Conversation.php b/components/Conversation/Conversation.php index 43a7fdb4fb..aa8d9ab519 100644 --- a/components/Conversation/Conversation.php +++ b/components/Conversation/Conversation.php @@ -99,7 +99,7 @@ class Conversation extends Component // Get actors who replied foreach ($note_replies as $reply) { - $reply_actor[] = Actor::getWithPK(Note::getWithPK($reply)->getActorId()); + $reply_actor[] = Actor::getWithPK($reply->getActorId()); } if (\count($reply_actor) < 1) { return Event::next; diff --git a/plugins/TreeNotes/TreeNotes.php b/plugins/TreeNotes/TreeNotes.php index a1885ce9f9..c29dd56e72 100644 --- a/plugins/TreeNotes/TreeNotes.php +++ b/plugins/TreeNotes/TreeNotes.php @@ -23,7 +23,6 @@ namespace Plugin\TreeNotes; use App\Core\Modules\Plugin; use App\Entity\Note; -use Component\Reply\Entity\NoteReply; class TreeNotes extends Plugin { @@ -32,7 +31,7 @@ class TreeNotes extends Plugin */ public function onFormatNoteList(array $notes_in, ?array &$notes_out) { - $roots = array_filter($notes_in, fn (Note $note) => \is_null($note->getReplyTo())); + $roots = array_filter($notes_in, static fn (Note $note) => is_null($note->getReplyTo())); $notes_out = $this->build_tree($roots, $notes_in); } @@ -47,7 +46,7 @@ class TreeNotes extends Plugin private function build_subtree(Note $parent, array $notes) { - $children = array_filter($notes, fn (Note $note) => $parent->getId() === $note->getReplyTo()); + $children = array_filter($notes, fn (Note $note) => $note->getReplyTo() === $parent->getId()); return ['note' => $parent, 'replies' => $this->build_tree($children, $notes)]; } } diff --git a/src/Entity/Note.php b/src/Entity/Note.php index 6d23d1bc0a..db2a50423c 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -122,7 +122,7 @@ class Note extends Entity public function getReplyTo(): ?int { - return $this->reply_to; + return $this->reply_to ?: null; } public function setIsLocal(bool $is_local): self @@ -317,9 +317,10 @@ class Note extends Entity return self::getWithPK($this->getReplyTo()); } - public function getReplies(): array + public function getReplies() { - return Cache::getList('note-replies-' . $this->id, fn () => DB::dql('select n from note n where n.reply_to = :id', ['id' => $this->id])); + $id = $this->getId(); + return Cache::get('note-replies-' . $id, fn () => DB::dql('select n from note n where n.reply_to = :id', ['id' => $id])); } /**