diff --git a/VKAPI/Handlers/Audio.php b/VKAPI/Handlers/Audio.php index b25285c0..9f6d3003 100644 --- a/VKAPI/Handlers/Audio.php +++ b/VKAPI/Handlers/Audio.php @@ -462,7 +462,11 @@ final class Audio extends VKAPIRequestHandler else if(!$audio->canBeViewedBy($this->getUser())) $this->fail(201, "Access denied to audio(owner=$owner_id, vid=$audio_id)"); - $audio->add($to); + try { + $audio->add($to); + } catch(\OverflowException $ex) { + $this->fail(300, "Album is full"); + } return $audio->getPrettyId(); } diff --git a/Web/Models/Entities/Audio.php b/Web/Models/Entities/Audio.php index f758692d..73ffb8f4 100644 --- a/Web/Models/Entities/Audio.php +++ b/Web/Models/Entities/Audio.php @@ -266,8 +266,13 @@ class Audio extends Media if($this->isInLibraryOf($entity)) return false; - DatabaseConnection::i()->getContext()->table("audio_relations")->insert([ - "entity" => $entity->getId() * ($entity instanceof Club ? -1 : 1), + $entityId = $entity->getId() * ($entity instanceof Club ? -1 : 1); + $audioRels = DatabaseConnection::i()->getContext()->table("audio_relations"); + if(sizeof($audioRels->where("entity", $entityId)) > 65536) + throw new \OverflowException("Can't have more than 65536 audios in a playlist"); + + $audioRels->insert([ + "entity" => $entityId, "audio" => $this->getId(), ]);