From 57d4f9da2d4b7343ebd87d7c3ffe0b525ce7895f Mon Sep 17 00:00:00 2001 From: veselcraft Date: Tue, 28 Dec 2021 18:45:56 +0300 Subject: [PATCH] Users: getByShortURL improvements --- Web/Models/Repositories/Users.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Web/Models/Repositories/Users.php b/Web/Models/Repositories/Users.php index ae31db8d..cc757cc8 100644 --- a/Web/Models/Repositories/Users.php +++ b/Web/Models/Repositories/Users.php @@ -30,14 +30,15 @@ class Users function getByShortURL(string $url, bool $handleId = false): ?User { - $user = $this->toUser($this->users->where("shortcode", $url)->fetch()); - if($user) + $user = $this->toUser((clone $this->users)->where("shortcode", $url)->fetch()); + if($user !== null) return $user; else if ($handleId == true) { $id = array(); preg_match("/id([0-9]+)/", $url, $id); - return $this->toUser($this->users->get($id[1])); + $id = intval($id[1]); + return $this->get($id); } return null; }