From 75da577e4cc053af0a1ef070cb2f4e4558134b28 Mon Sep 17 00:00:00 2001 From: Kristiaan Van den Eynde Date: Thu, 25 May 2017 15:57:13 +0200 Subject: [PATCH] interdiff --- core/modules/user/src/Entity/User.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index f376040..2271bb3 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -82,11 +82,14 @@ public function preSave(EntityStorageInterface $storage) { // Make sure that the authenticated, anonymous and superuser roles are not // actually saved to the database. - foreach ($this->get('roles') as $index => $item) { - if (in_array($item->target_id, [RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID, RoleInterface::SUPERUSER_ID])) { - $this->get('roles')->offsetUnset($index); + $internal = [RoleInterface::ANONYMOUS_ID, RoleInterface::AUTHENTICATED_ID, RoleInterface::SUPERUSER_ID]; + $role_refs = $this->get('roles')->getValue(); + foreach ($role_refs as $index => $role_ref) { + if (in_array($role_ref['target_id'], $internal)) { + unset($role_refs[$index]); } } + $this->get('roles')->setValue($role_refs); // Store account cancellation information. foreach (['user_cancel_method', 'user_cancel_notify'] as $key) { -- 2.8.1