From 9d62bfc12e3b8d989b6efe759bf11290f1290514 Mon Sep 17 00:00:00 2001 From: Ry0 <43928323+xRy0@users.noreply.github.com> Date: Mon, 1 Jul 2024 22:43:56 +0300 Subject: [PATCH] fix audio.add (#1121) * fix audio.add * Fix settype to allow Null * thx celestora <3 * Finaly, Tarhun --- VKAPI/Handlers/Audio.php | 2 +- Web/Presenters/VKAPIPresenter.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/VKAPI/Handlers/Audio.php b/VKAPI/Handlers/Audio.php index 413a2a3a0..004daef49 100644 --- a/VKAPI/Handlers/Audio.php +++ b/VKAPI/Handlers/Audio.php @@ -485,7 +485,7 @@ function add(int $audio_id, int $owner_id, ?int $group_id = NULL, ?int $album_id $this->requireUser(); $this->willExecuteWriteAction(); - if(!is_null($album_id)) + if(!is_null($album_id)) $this->fail(10, "album_id not implemented"); // TODO get rid of dups diff --git a/Web/Presenters/VKAPIPresenter.php b/Web/Presenters/VKAPIPresenter.php index e906ce50e..d82194cf2 100644 --- a/Web/Presenters/VKAPIPresenter.php +++ b/Web/Presenters/VKAPIPresenter.php @@ -234,8 +234,14 @@ function renderRoute(string $object, string $method): void } try { - settype($val, $parameter->getType()->getName()); - $params[] = $val; + // Проверка типа параметра + $type = $parameter->getType(); + if (($type && !$type->isBuiltin()) || is_null($val)) { + $params[] = $val; + } else { + settype($val, $parameter->getType()->getName()); + $params[] = $val; + } } catch (\Throwable $e) { // Just ignore the exception, since // some args are intended for internal use