diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index b157be34d0..0e35a52d1a 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -359,7 +359,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) { // numeric keys. Allow to override this per field. As this function is // called twice, we have to prevent it from getting the array keys twice. - if (is_string(key($form_state->getValue('roles')))) { + if (is_string(key( (array) $form_state->getValue('roles')))) { $form_state->setValue('roles', array_keys(array_filter($form_state->getValue('roles')))); }