fix(VKAPI/Handlers/Notes): move $nodez declaration up

This commit is contained in:
Alexander Minkin 2025-02-09 17:27:51 +03:00
parent a1f5fcbe88
commit f672e5001a
Signed by untrusted user: WerySkok
GPG key ID: 88E9A2F3AFE44C30

View file

@ -185,12 +185,14 @@ final class Notes extends VKAPIRequestHandler
$this->fail(15, "Access denied");
}
if (empty($note_ids)) {
$notes = array_slice(iterator_to_array((new NotesRepo())->getUserNotes($user, 1, $count + $offset, $sort == 0 ? "ASC" : "DESC")), $offset);
$nodez = (object) [
"count" => (new NotesRepo())->getUserNotesCount((new UsersRepo())->get($user_id)),
"count" => 0,
"notes" => [],
];
if (empty($note_ids)) {
$nodez->count = (new NotesRepo())->getUserNotesCount($user);
$notes = array_slice(iterator_to_array((new NotesRepo())->getUserNotes($user, 1, $count + $offset, $sort == 0 ? "ASC" : "DESC")), $offset);
foreach ($notes as $note) {
if ($note->isDeleted()) {
@ -210,6 +212,7 @@ final class Notes extends VKAPIRequestHandler
$note = (new NotesRepo())->getNoteById((int) $id[0], (int) $id[1]);
if ($note && !$note->isDeleted()) {
$nodez->notes[] = $note->toVkApiStruct();
$nodez->count++;
}
}
}