diff --git a/src/Module/Moderation/Users/Active.php b/src/Module/Moderation/Users/Active.php index 24634157b5..b16efa46ae 100644 --- a/src/Module/Moderation/Users/Active.php +++ b/src/Module/Moderation/Users/Active.php @@ -48,15 +48,18 @@ class Active extends BaseUsers { parent::content(); - $action = $this->parameters['action'] ?? ''; - $uid = $this->parameters['uid'] ?? 0; + $action = (string) $this->parameters['action'] ?? ''; + $uid = (int) $this->parameters['uid'] ?? 0; - if ($uid) { - $user = User::getById($uid, ['username', 'blocked']); - if (!$user) { - $this->systemMessages->addNotice($this->t('User not found')); - $this->baseUrl->redirect('moderation/users'); - } + if ($uid === 0) { + $this->systemMessages->addNotice($this->t('User not found')); + $this->baseUrl->redirect('moderation/users'); + } + + $user = User::getById($uid, ['username', 'blocked']); + if (!is_array($user)) { + $this->systemMessages->addNotice($this->t('User not found')); + $this->baseUrl->redirect('moderation/users'); } switch ($action) { diff --git a/src/Module/Moderation/Users/Blocked.php b/src/Module/Moderation/Users/Blocked.php index fd8d25dfbe..6eeb11549f 100644 --- a/src/Module/Moderation/Users/Blocked.php +++ b/src/Module/Moderation/Users/Blocked.php @@ -48,15 +48,18 @@ class Blocked extends BaseUsers { parent::content(); - $action = $this->parameters['action'] ?? ''; - $uid = $this->parameters['uid'] ?? 0; + $action = (string) $this->parameters['action'] ?? ''; + $uid = (int) $this->parameters['uid'] ?? 0; - if ($uid) { - $user = User::getById($uid, ['username', 'blocked']); - if (!$user) { - $this->systemMessages->addNotice($this->t('User not found')); - $this->baseUrl->redirect('moderation/users'); - } + if ($uid === 0) { + $this->systemMessages->addNotice($this->t('User not found')); + $this->baseUrl->redirect('moderation/users'); + } + + $user = User::getById($uid, ['username', 'blocked']); + if (!is_array($user)) { + $this->systemMessages->addNotice($this->t('User not found')); + $this->baseUrl->redirect('moderation/users'); } switch ($action) { diff --git a/src/Module/Moderation/Users/Index.php b/src/Module/Moderation/Users/Index.php index 6553bcc7e3..1a7d8f1721 100644 --- a/src/Module/Moderation/Users/Index.php +++ b/src/Module/Moderation/Users/Index.php @@ -55,15 +55,18 @@ class Index extends BaseUsers { parent::content(); - $action = $this->parameters['action'] ?? ''; - $uid = $this->parameters['uid'] ?? 0; + $action = (string) $this->parameters['action'] ?? ''; + $uid = (int) $this->parameters['uid'] ?? 0; - if ($uid) { - $user = User::getById($uid, ['username', 'blocked']); - if (!$user) { - $this->systemMessages->addNotice($this->t('User not found')); - $this->baseUrl->redirect('moderation/users'); - } + if ($uid === 0) { + $this->systemMessages->addNotice($this->t('User not found')); + $this->baseUrl->redirect('moderation/users'); + } + + $user = User::getById($uid, ['username', 'blocked']); + if (!is_array($user)) { + $this->systemMessages->addNotice($this->t('User not found')); + $this->baseUrl->redirect('moderation/users'); } switch ($action) {