Users: getByShortURL improvements

This commit is contained in:
veselcraft 2021-12-28 18:45:56 +03:00
parent 7557d6779b
commit 57d4f9da2d
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E

View file

@ -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;
}