From b1111101b53fce0210145c32d2038107272fdd80 Mon Sep 17 00:00:00 2001 From: veselcraft Date: Fri, 28 Feb 2025 18:34:44 +0300 Subject: [PATCH] fix(stan): all errors are gone now =3 --- Web/Models/Entities/Photo.php | 2 +- Web/Models/Repositories/Conversations.php | 53 ----------------------- Web/Presenters/ContentSearchPresenter.php | 8 ++-- Web/Themes/Themepack.php | 2 +- Web/Themes/Themepacks.php | 19 -------- Web/Util/Bitmask.php | 4 +- 6 files changed, 8 insertions(+), 80 deletions(-) delete mode 100644 Web/Models/Repositories/Conversations.php diff --git a/Web/Models/Entities/Photo.php b/Web/Models/Entities/Photo.php index faa09ae8..470a0a8a 100644 --- a/Web/Models/Entities/Photo.php +++ b/Web/Models/Entities/Photo.php @@ -387,7 +387,7 @@ class Photo extends Media public static function fastMake(int $owner, string $description, array $file, ?Album $album = null, bool $anon = false): Photo { - $photo = new static(); + $photo = new Photo(); $photo->setOwner($owner); $photo->setDescription(iconv_substr($description, 0, 36) . "..."); $photo->setAnonymous($anon); diff --git a/Web/Models/Repositories/Conversations.php b/Web/Models/Repositories/Conversations.php deleted file mode 100644 index e354411b..00000000 --- a/Web/Models/Repositories/Conversations.php +++ /dev/null @@ -1,53 +0,0 @@ -context = DB::i()->getContext(); - $this->convos = $this->context->table("conversations"); - } - - private function toConversation(?ActiveRow $ar): ?M\AbstractConversation - { - if (is_null($ar)) { - return null; - } elseif ($ar->is_pm) { - return new M\PrivateConversation($ar); - } else { - return new M\Conversation($ar); - } - } - - public function get(int $id): ?M\AbstractConversation - { - return $this->toConversation($this->convos->get($id)); - } - - public function getConversationsByUser(User $user, int $page = 1, ?int $perPage = null): \Traversable - { - $rels = $this->context->table("conversation_members")->where([ - "deleted" => false, - "user" => $user->getId(), - ])->page($page, $perPage ?? OPENVK_DEFAULT_PER_PAGE); - foreach ($rels as $rel) { - yield $this->get($rel->conversation); - } - } - - public function getPrivateConversation(User $user, int $peer): M\PrivateConversation - { - ; - } -} diff --git a/Web/Presenters/ContentSearchPresenter.php b/Web/Presenters/ContentSearchPresenter.php index c68a51c2..e22f34fa 100644 --- a/Web/Presenters/ContentSearchPresenter.php +++ b/Web/Presenters/ContentSearchPresenter.php @@ -8,17 +8,17 @@ use openvk\Web\Models\Repositories\ContentSearchRepository; final class ContentSearchPresenter extends OpenVKPresenter { - private $repo; + protected $repo; - public function __construct(ContentSearchRepository $repo) + public function __construct(ContentSearchRepository $repository) { - $this->repo = $repo; + $this->repo = $repository; } public function renderIndex(): void { if ($_SERVER["REQUEST_METHOD"] === "POST") { - $this->template->results = $this->$repo->find([ + $this->template->results = $this->repo->find([ "query" => $this->postParam("query"), ]); } diff --git a/Web/Themes/Themepack.php b/Web/Themes/Themepack.php index be2b2c11..01e41a3b 100644 --- a/Web/Themes/Themepack.php +++ b/Web/Themes/Themepack.php @@ -128,6 +128,6 @@ class Themepack throw new Exceptions\IncompatibleThemeException("Theme is built for newer OVK (themeEngine" . $manifest->openvk_version . ")"); } - return new static($manifest->id, $manifest->version, (bool) ($manifest->inherit_master ?? true), (bool) ($manifest->override_templates ?? false), (bool) ($manifest->enabled ?? true), (object) $manifest->metadata); + return new Themepack($manifest->id, $manifest->version, (bool) ($manifest->inherit_master ?? true), (bool) ($manifest->override_templates ?? false), (bool) ($manifest->enabled ?? true), (object) $manifest->metadata); } } diff --git a/Web/Themes/Themepacks.php b/Web/Themes/Themepacks.php index 1907553a..7acc9dcd 100644 --- a/Web/Themes/Themepacks.php +++ b/Web/Themes/Themepacks.php @@ -88,25 +88,6 @@ class Themepacks implements \ArrayAccess /* /ArrayAccess */ - public function install(string $archivePath): bool - { - if (!file_exists($archivePath)) { - return false; - } - - $tmpDir = mkdir(tempnam(OPENVK_ROOT . "/tmp/themepack_artifacts/", "themex_")); - try { - $archive = new \CabArchive($archivePath); - $archive->extract($tmpDir); - - return $this->installUnpacked($tmpDir); - } catch (\Exception $e) { - return false; - } finally { - rmdir($tmpDir); - } - } - public function uninstall(string $id): bool { if (!isset($loadedThemepacks[$id])) { diff --git a/Web/Util/Bitmask.php b/Web/Util/Bitmask.php index c34fcdc6..c8fb7504 100644 --- a/Web/Util/Bitmask.php +++ b/Web/Util/Bitmask.php @@ -78,7 +78,7 @@ class Bitmask } elseif (gettype($key) === "int") { $this->setByOffset($key, $data); } else { - throw new TypeError("Key must be either offset (int) or a string index"); + throw new \TypeError("Key must be either offset (int) or a string index"); } return $this; @@ -89,7 +89,7 @@ class Bitmask if (gettype($key) === "string") { $key = $this->getOffsetByKey($key); } elseif (gettype($key) !== "int") { - throw new TypeError("Key must be either offset (int) or a string index"); + throw new \TypeError("Key must be either offset (int) or a string index"); } return $this->length === 1 ? $this->getBoolByOffset($key) : $this->getNumberByOffset($key);