reverted: --- b/core/lib/Drupal/Core/Session/UserSession.php +++ a/core/lib/Drupal/Core/Session/UserSession.php @@ -141,7 +141,15 @@ return TRUE; } + $roles = \Drupal::entityManager()->getStorage('user_role')->loadMultiple($this->getRoles()); + + foreach ($roles as $role) { + if ($role->hasPermission($permission)) { + return TRUE; + } + } + + return FALSE; - return $this->getRoleStorage()->isPermissionInRoles($permission, $this->getRoles()); } /** @@ -242,14 +250,4 @@ return $this->hostname; } - /** - * Returns the role storage object. - * - * @return \Drupal\user\RoleStorageInterface - * The role storage object. - */ - protected function getRoleStorage() { - return \Drupal::entityManager()->getStorage('user_role'); - } - } reverted: --- b/core/modules/user/src/Entity/User.php +++ a/core/modules/user/src/Entity/User.php @@ -242,7 +242,15 @@ return TRUE; } + $roles = \Drupal::entityManager()->getStorage('user_role')->loadMultiple($this->getRoles()); + + foreach ($roles as $role) { + if ($role->hasPermission($permission)) { + return TRUE; + } + } + + return FALSE; - return $this->getRoleStorage()->isPermissionInRoles($permission, $this->getRoles()); } /** @@ -526,14 +534,4 @@ return $fields; } - /** - * Returns the role storage object. - * - * @return \Drupal\user\RoleStorageInterface - * The role storage object. - */ - protected function getRoleStorage() { - return \Drupal::entityManager()->getStorage('user_role'); - } - } reverted: --- b/core/modules/user/src/RoleStorage.php +++ a/core/modules/user/src/RoleStorage.php @@ -17,21 +17,6 @@ /** * {@inheritdoc} */ - public function isPermissionInRoles($permission, array $rids) { - $has_permission = FALSE; - foreach ($this->loadMultiple($rids) as $role) { - if ($role->hasPermission($permission)) { - $has_permission = TRUE; - break; - } - } - - return $has_permission; - } - - /** - * {@inheritdoc} - */ public function deleteRoleReferences(array $rids) { // Remove the role from all users. db_delete('users_roles') reverted: --- b/core/modules/user/src/RoleStorageInterface.php +++ a/core/modules/user/src/RoleStorageInterface.php @@ -15,19 +15,6 @@ interface RoleStorageInterface extends ConfigEntityStorageInterface { /** - * Returns whether a permission is in one of the passed in roles. - * - * @param string $permission - * The permission. - * @param array $rids - * The list of role IDs to check. - * - * @return bool - * TRUE is the permission is in at least one of the roles. FALSE otherwise. - */ - public function isPermissionInRoles($permission, array $rids); - - /** * Delete role references. * * @param array $rids only in patch2: unchanged: --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -648,9 +648,6 @@ protected function doDelete($entities) { $this->invokeFieldMethod('delete', $entity); $this->deleteFieldItems($entity); } - - // Reset the cache as soon as the changes have been applied. - $this->resetCache($ids); } /** @@ -709,7 +706,6 @@ protected function doSave($id, EntityInterface $entity) { if ($this->revisionTable) { $entity->setNewRevision(FALSE); } - $cache_ids = array($entity->id()); } else { // Ensure the entity is still seen as new after assigning it an id, @@ -742,12 +738,9 @@ protected function doSave($id, EntityInterface $entity) { if ($this->revisionTable) { $entity->setNewRevision(FALSE); } - // Reset general caches, but keep caches specific to certain entities. - $cache_ids = array(); } $this->invokeFieldMethod($is_new ? 'insert' : 'update', $entity); $this->saveFieldItems($entity, !$is_new); - $this->resetCache($cache_ids); if (!$is_new && $this->dataTable) { $this->invokeTranslationHooks($entity); only in patch2: unchanged: --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -339,14 +339,18 @@ public function delete(array $entities) { return; } + // Allow code to run before deleting. $entity_class = $this->entityClass; $entity_class::preDelete($this, $entities); foreach ($entities as $entity) { $this->invokeHook('predelete', $entity); } + // Perform the delete and reset the static cache for the deleted entities. $this->doDelete($entities); + $this->resetCache(array_keys($entities)); + // Allow code to run after deleting. $entity_class::postDelete($this, $entities); foreach ($entities as $entity) { $this->invokeHook('delete', $entity); @@ -391,8 +395,9 @@ public function save(EntityInterface $entity) { $entity->preSave($this); $this->invokeHook('presave', $entity); - // Perform the save. + // Perform the save and reset the static cache for the changed entity. $return = $this->doSave($id, $entity); + $this->resetCache(array($id)); // The entity is no longer new. $entity->enforceIsNew(FALSE);