From 76245038d5bf3821094d3e8b4f20dbf251b9300b Mon Sep 17 00:00:00 2001 From: Alexander Minkin Date: Tue, 20 May 2025 13:44:22 +0300 Subject: [PATCH 1/4] feat(phpstan): upgrade to level 1 --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 4831b3150..d708f5471 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 0 + level: 1 paths: - CLI - ServiceAPI From e7bf94f861bc570a98d11e11b42328b7af705dd7 Mon Sep 17 00:00:00 2001 From: Alexander Minkin Date: Tue, 5 Aug 2025 00:31:19 +0300 Subject: [PATCH 2/4] fix(bootstrap): check for link existability before adding 'https://' --- bootstrap.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index f9d609e29..659d4565d 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -392,15 +392,15 @@ function ovk_scheme(bool $with_slashes = false): string function check_copyright_link(string $link = ''): bool { - if (!str_contains($link, "https://") && !str_contains($link, "http://")) { - $link = "https://" . $link; - } - # Existability if (is_null($link) || empty($link)) { throw new \InvalidArgumentException("Empty link"); } + if (!str_contains($link, "https://") && !str_contains($link, "http://")) { + $link = "https://" . $link; + } + # Length if (iconv_strlen($link) < 2 || iconv_strlen($link) > 400) { throw new \LengthException("Link is too long"); From d397c68601a6ddf3e2eb2eb128089a9caab87602 Mon Sep 17 00:00:00 2001 From: Alexander Minkin Date: Tue, 5 Aug 2025 01:30:28 +0300 Subject: [PATCH 3/4] fix: solve PHP 8 warnings detected by Tracy on local instance not directly related to PHPStan but nice to have anyway --- Web/Models/Repositories/Audios.php | 2 +- Web/Presenters/OpenVKPresenter.php | 2 +- Web/Presenters/templates/@layout.xml | 36 ++++++++++---------- Web/Presenters/templates/Admin/Logs.xml | 22 ++++++------ Web/Presenters/templates/Audio/bigplayer.xml | 2 +- install/automated/docker/openvk.example.yml | 2 ++ openvk-example.yml | 2 ++ 7 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Web/Models/Repositories/Audios.php b/Web/Models/Repositories/Audios.php index 5be250ff4..94a6278bc 100644 --- a/Web/Models/Repositories/Audios.php +++ b/Web/Models/Repositories/Audios.php @@ -270,7 +270,7 @@ public function find(string $query, array $params = [], array $order = ['type' = $order_str = (in_array($order['type'], ['id', 'length', 'listens']) ? $order['type'] : 'id') . ' ' . ($order['invert'] ? 'ASC' : 'DESC'); ; - if ($params["only_performers"] == "1") { + if ($params["only_performers"] ?? null == "1") { $result->where("performer LIKE ?", $query); } else { $result->where("CONCAT_WS(' ', performer, name) LIKE ?", $query); diff --git a/Web/Presenters/OpenVKPresenter.php b/Web/Presenters/OpenVKPresenter.php index 3ed99a9c2..ed458e32c 100644 --- a/Web/Presenters/OpenVKPresenter.php +++ b/Web/Presenters/OpenVKPresenter.php @@ -317,7 +317,7 @@ public function onStartup(): void } } - if ($_SERVER['HTTP_X_OPENVK_AJAX_QUERY'] == '1' && $this->user->identity) { + if (!empty($_SERVER['HTTP_X_OPENVK_AJAX_QUERY']) && $_SERVER['HTTP_X_OPENVK_AJAX_QUERY'] == '1' && $this->user->identity) { error_reporting(0); header('Content-Type: text/plain; charset=UTF-8'); } diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index 34e721961..77b1d9d1f 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -102,7 +102,7 @@
-
+
{if $instance_name != OPENVK_DEFAULT_INSTANCE_NAME}{$instance_name}{/if}
{ifset $thisUser} @@ -133,16 +133,16 @@
- +