From 4bf6fce260ee5e83ac901dc443530168346c3f04 Mon Sep 17 00:00:00 2001 From: veselcraft Date: Fri, 25 Mar 2022 14:44:10 +0300 Subject: [PATCH] VKAPI: Fix 500 error if the post is published as anon --- VKAPI/Handlers/Wall.php | 2 +- Web/Models/Repositories/Albums.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index 5b0035de..a87b1e63 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -31,7 +31,7 @@ final class Wall extends VKAPIRequestHandler $attachments[] = [ "type" => "photo", "photo" => [ - "album_id" => $attachment->getAlbum()->getId(), + "album_id" => $attachment->getAlbum() ? $attachment->getAlbum()->getId() : null, "date" => $attachment->getPublicationTime()->timestamp(), "id" => $attachment->getVirtualId(), "owner_id" => $attachment->getOwner()->getId(), diff --git a/Web/Models/Repositories/Albums.php b/Web/Models/Repositories/Albums.php index 0da26ff0..0995a073 100644 --- a/Web/Models/Repositories/Albums.php +++ b/Web/Models/Repositories/Albums.php @@ -121,6 +121,6 @@ class Albums { $dbalbum = DatabaseConnection::i()->getContext()->table("album_relations")->where(["media" => $photo->getId()])->fetch(); - return $this->get($dbalbum->collection); + return $dbalbum->collection ? $this->get($dbalbum->collection) : null; } }