diff --git a/src/User/Hydrator/UserHydrator.php b/src/User/Hydrator/UserHydrator.php index 993517fa..7e0d16d2 100644 --- a/src/User/Hydrator/UserHydrator.php +++ b/src/User/Hydrator/UserHydrator.php @@ -58,7 +58,7 @@ classes: $user->getClasses(), lastLogin: $user->getLastLogin(), memorizeTabs: $user->getMemorizeTabs(), parentId: $user->getParentId(), - permissions: $user->getPermissions(), + permissions: $this->sanitizePermissions($user->getPermissions()), roles: $user->getRoles(), twoFactorAuthenticationEnabled: $user->getTwoFactorAuthentication('enabled') || $user->getTwoFactorAuthentication('secret'), @@ -108,4 +108,11 @@ private function getContentLanguages(UserInterface $user): array return explode(',', $contentLanguagesString); } + + // In some cases, the permissions array contains and array with empty strings as values + // This method removes those empty strings + private function sanitizePermissions(array $permissions): array + { + return array_filter($permissions, fn ($permission) => $permission !== ''); + } }