Skip to content

Commit

Permalink
Fix checks that should have been for nonzero-length arrays
Browse files Browse the repository at this point in the history
Fixes #949
  • Loading branch information
iansltx committed May 24, 2024
1 parent d204fd6 commit 32346a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function postAction(Request $request, PDO $db): void
// does anyone else have this username?
$existingUser = $userMapper->getUserByUsername($user['username']);

if (is_array($existingUser) && array_key_exists('users', $existingUser)) {
if (is_array($existingUser) && count($existingUser['users'] ?? [])) {
if (count($existingUser['users']) > 0) {
$errors[] = "That username is already in use. Choose another";
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public function postAction(Request $request, PDO $db): void
// does anyone else have this email?
$existingUser = $userMapper->getUserByEmail($user['email']);

if (is_array($existingUser) && array_key_exists('users', $existingUser)) {
if (is_array($existingUser) && count($existingUser['users'] ?? [])) {
if (count($existingUser['users']) > 0) {
$errors[] = "That email is already associated with another account";
}
Expand Down Expand Up @@ -328,7 +328,7 @@ public function updateUser(Request $request, PDO $db)
// does anyone else have this email?
$existingUser = $userMapper->getUserByEmail($user['email']);

if (is_array($existingUser) && array_key_exists('users', $existingUser)) {
if (is_array($existingUser) && count($existingUser['users'] ?? [])) {
// yes but is that our existing user being found?
$oldUser = $userMapper->getUserById($userId);

Expand Down

0 comments on commit 32346a7

Please sign in to comment.