From 01078e20fbbeee4a739d4d62c769da6a134d3a2c Mon Sep 17 00:00:00 2001 From: Eliseu Amaro Date: Mon, 29 Nov 2021 14:50:25 +0000 Subject: [PATCH] [PLUGINS][Reply] Fix return on getReplyToNote The array contained an object, the result was within that object and not the object itself. --- plugins/Reply/Entity/NoteReply.php | 4 ++-- plugins/TreeNotes/TreeNotes.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/Reply/Entity/NoteReply.php b/plugins/Reply/Entity/NoteReply.php index 3112b911ea..7d0755aea3 100644 --- a/plugins/Reply/Entity/NoteReply.php +++ b/plugins/Reply/Entity/NoteReply.php @@ -95,8 +95,8 @@ class NoteReply extends Entity $result = DB::dql('select nr.reply_to from note_reply nr ' . 'where nr.note_id = :note_id', ['note_id' => $note->getId()], ); - if (!\is_null($result) && \array_key_exists('reply_to', $result)) { - return $result['reply_to']; + if (!\is_null($result) && \array_key_exists(0, $result)) { + return $result[0]['reply_to']; } return null; diff --git a/plugins/TreeNotes/TreeNotes.php b/plugins/TreeNotes/TreeNotes.php index e63182bb3c..2d5589a37c 100644 --- a/plugins/TreeNotes/TreeNotes.php +++ b/plugins/TreeNotes/TreeNotes.php @@ -32,7 +32,7 @@ class TreeNotes extends Plugin */ public function onFormatNoteList(array $notes_in, ?array &$notes_out) { - $roots = array_filter($notes_in, fn (Note $note) => NoteReply::getReplyToNote($note) == null); + $roots = array_filter($notes_in, fn (Note $note) => \is_null(NoteReply::getReplyToNote($note))); $notes_out = $this->build_tree($roots, $notes_in); } @@ -47,7 +47,7 @@ class TreeNotes extends Plugin private function build_subtree(Note $parent, array $notes) { - $children = array_filter($notes, fn (Note $note) => $parent->getId() == NoteReply::getReplyToNote($note)); + $children = array_filter($notes, fn (Note $note) => $parent->getId() === NoteReply::getReplyToNote($note)); return ['note' => $parent, 'replies' => $this->build_tree($children, $notes)]; } }