Update PPost model

This commit is contained in:
Visman 2021-12-04 19:27:45 +07:00
parent 6fcf3c6807
commit 1d72e0a018

View file

@ -64,21 +64,15 @@ class PPost extends DataModel
protected function getuser(): User
{
$user = $this->c->users->load($this->poster_id);
if (
! $user instanceof User
&& 1 !== $this->poster_id // ???? может сменить id гостя?
$this->poster_id < 1
|| ! ($user = $this->c->users->load($this->poster_id)) instanceof User
) {
$user = $this->c->users->load(1);
$user = $this->c->users->guest(['username' => $this->poster]);
}
if (! $user instanceof User) {
throw new RuntimeException("No user data in ppost number {$this->id}");
} elseif ($user->isGuest) {
$user = clone $user;
$user->__username = $this->poster;
}
return $user;