From 32346a71e4dbc4be41a34f07a975a939fe59699d Mon Sep 17 00:00:00 2001 From: Ian Littman Date: Fri, 24 May 2024 12:20:38 -0500 Subject: [PATCH] Fix checks that should have been for nonzero-length arrays Fixes #949 --- src/Controller/UsersController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index 6a77e03f..4f08cf18 100644 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -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"; } @@ -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"; } @@ -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);